title: Is there a C# sdk/wrapper for Azure Resource Management API calls?
body: <p>I want to execute resource group based calls. For example:
  <a href="https://msdn.microsoft.com/en-us/library/azure/mt163572.aspx" rel="nofollow">https://msdn.microsoft.com/en-us/library/azure/mt163572.aspx</a></p>
  
  <p>Azure Management Libraries don't seem to have this capability (unless I'm missing something). Is there any SDK or client wrapper available that can make that kind of call?</p>
  
  <p>EDIT:
  Gaurav pointed me at exactly what I needed. Going to do people a solid and expand upon what I did to help clear the muddy muddy waters that is the Azure Resource Management API. </p>
  
  <p>In your app's Packet Manager do:
  Install-Package Microsoft.Azure.Management.Resources -Pre
  Then
  Install-Package Microsoft.Azure.Management.Compute -Pre
  Then
  Install-Package Microsoft.IdentityModel.Clients.ActiveDirectory -Pre</p>
  
  <p>Follow this blog for getting an authorization header/token:
  <a href="https://msdn.microsoft.com/en-us/library/azure/dn722415.aspx" rel="nofollow">https://msdn.microsoft.com/en-us/library/azure/dn722415.aspx</a></p>
  
  <p>Then call the new API like so (note the slight name changes):</p>
  
  <pre><code>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(() =&gt;
          {
              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 to obtain the JWT token");
          }
  
          string token = result.AccessToken;
          return token;
      }
  }
  </code></pre>