title: Azure .NET SDK - List all virtual machines, failed to authenticate
body: <p>Using the new <a href="https://github.com/WindowsAzure/azure-sdk-for-net/" rel="nofollow noreferrer">Windows Azure SDK for .NET</a>, I want to get a list of all virtual machines.</p>
  
  <p>Piecing together the early documentation, here's what I came up with:</p>
  
  <pre><code>// This is a custom cert I made locally. I uploaded it to Azure's Management Certificates and added it to my local computer's cert store, see screenshot below.
  X509Certificate2 myCustomCert = await this.GetAzureCert();
  var credentials = new CertificateCloudCredentials(mySubscriptionId, myCustomCert);
  
  using (var cloudServiceClient = CloudContext.Clients.CreateCloudServiceManagementClient(credentials))
  {
      credentials.InitializeServiceClient(cloudServiceClient); // Is this required? The next call fails either way.
  
      // This line fails with exception: "The server failed to authenticate the request. Verify that the certificate is valid and is associated with this subscription."
      var services = await cloudServiceClient.CloudServices.ListAsync(CancellationToken.None);
  }
  </code></pre>
  
  <p>My first thought was the cert was bad, but I am able to successfully call the Azure REST API using my custom certificate. As you can see below, it is properly added to the Azure Management Certificates and associated with my subscription:</p>
  
  <p><img src="https://i.stack.imgur.com/TuR5O.jpg" alt="enter image description here"></p>
  
  <p>What am I doing wrong?</p>