Created
November 7, 2013 01:20
-
-
Save sandrinodimattia/7347313 to your computer and use it in GitHub Desktop.
ServiceManagement Authentication
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class CertificateCloudCredentialsFactory | |
{ | |
public static CertificateCloudCredentials FromPublishSettingsFile(string path, string subscriptionName) | |
{ | |
var profile = XDocument.Load(path); | |
var subscriptionId = profile.Descendants("Subscription") | |
.First(element => element.Attribute("Name").Value == subscriptionName) | |
.Attribute("Id").Value; | |
var certificate = new X509Certificate2( | |
Convert.FromBase64String(profile.Descendants("PublishProfile").Descendants("Subscription").Single().Attribute("ManagementCertificate").Value)); | |
return new CertificateCloudCredentials(subscriptionId, certificate); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment