Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I wrote some code below and verified that it works. It's based off Wade's post: <a href="http://www.wadewegner.com/2011/11/programmatically-installing-and-using-your-management-certificate-with-the-new-publishsettings-file/" rel="nofollow">Programmatically Installing and Using Your Management Certificate with the New .publishsettings File</a>. Then I call the <a href="http://msdn.microsoft.com/en-us/library/windowsazure/ee460785.aspx" rel="nofollow">Get Storage Account Keys</a> method. A couple pointers as mentioned in Wade's post: it's better to create a certificate and install it locally, then use it to call the SM API so that you can delete the .publishsettings file. It has your SM API cert info in it, so you should delete it or keep it safe. This code doesn't do the installing bit for brevity, but Wade's post has it.</p> <pre><code> var publishSettingsFile = @"C:\yourPublishSettingsFilePathGoesHere"; XDocument xdoc = XDocument.Load(publishSettingsFile); var managementCertbase64string = xdoc.Descendants("PublishProfile").Single().Attribute("ManagementCertificate").Value; var managementCert = new X509Certificate2( Convert.FromBase64String(managementCertbase64string)); // If you have more than one subscription, you'll need to change this string subscriptionId = xdoc.Descendants("Subscription").First().Attribute("Id").Value; string desiredStorageService = "yourStorageServiceName"; var req = (HttpWebRequest)WebRequest.Create( string.Format("https://management.core.windows.net/{0}/services/storageservices/{1}/keys", subscriptionId, desiredStorageService)); req.Headers["x-ms-version"] = "2012-08-01"; req.ClientCertificates.Add(managementCert); XNamespace xmlns = "http://schemas.microsoft.com/windowsazure"; XDocument response = XDocument.Load(req.GetResponse().GetResponseStream()); Console.WriteLine("Primary key: " + response.Descendants(xmlns + "Primary").First().Value); Console.WriteLine("Secondary key: " + response.Descendants(xmlns + "Secondary").First().Value); Console.Read(); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload