Is there a C# sdk/wrapper for Azure Resource Management API calls? -
i want execute resource group based calls. example: https://msdn.microsoft.com/en-us/library/azure/mt163572.aspx
azure management libraries don't seem have capability (unless i'm missing something). there sdk or client wrapper available can make kind of call?
edit: gaurav pointed me @ needed. going people solid , expand upon did clear muddy muddy waters azure resource management api.
in app's packet manager do: install-package microsoft.azure.management.resources -pre install-package microsoft.azure.management.compute -pre install-package microsoft.identitymodel.clients.activedirectory -pre
follow blog getting authorization header/token: https://msdn.microsoft.com/en-us/library/azure/dn722415.aspx
then call new api (note slight name changes):
class program { static void main(string[] args) { var token = getauthorizationheader(); var credential = new microsoft.rest.tokencredentials(token); using (var client = new computemanagementclient(credential) { subscriptionid = configurationmanager.appsettings["subscriptionid"] }) { var vms = client.virtualmachines.listall(); } } private static string getauthorizationheader() { authenticationresult result = null; var context = new authenticationcontext("https://login.windows.net/" + configurationmanager.appsettings["tenantid"]); string clientid = configurationmanager.appsettings["clientid"]; string clientsecret = configurationmanager.appsettings["clientsecret"]; clientcredential clientcred = new clientcredential(clientid, clientsecret); var thread = new thread(() => { result = context.acquiretoken( "https://management.core.windows.net/", clientcred); }); thread.setapartmentstate(apartmentstate.sta); thread.name = "aquiretokenthread"; thread.start(); thread.join(); if (result == null) { throw new invalidoperationexception("failed obtain jwt token"); } string token = result.accesstoken; return token; } }
i believe package you're looking microsoft.azure.management.resources 3.4.0-preview. can find complete source code azure resource manager here: https://github.com/azure/azure-sdk-for-net/tree/master/src/resourcemanagement.
Comments
Post a Comment