You can get this information only if you use Management Api.
Either REST, or you can use C # Windows Azure Management Libraries (Prerelease on nuget).
But note that you need to configure management certificates for information.
A simpler alternative is to create a parameter in your cloud service and set values when creating the deployment configuration. I do this and have a deployment configuration for the regions I am targeting.
using( var azure = CloudContext.Clients.CreateComputeManagementClient(...)) { var service = await azure.HostedServices.GetDetailedAsync("servicename");
Here ... these are credentials, or a management certificate, or your WAAD tokens. (ADAL: Active Directory Authentication Library) can be used for tokens.
here is the code to get the credentials from the certificate:
public static CertificateCloudCredentials GetCertificateCloudCredentials( string certificateThumbprint, string subscriptionId) { var certificate = CertificateHelper.LoadCertificate( StoreName.My, StoreLocation.LocalMachine, certificateThumbprint); if (certificate == null) throw new Exception( string.Format("Certificate with thumbprint '{0}' not found", certificateThumbprint)); var cred = new CertificateCloudCredentials( subscriptionId, certificate ); return cred; }
source share