According to my question here you will see that this is not happening. In addition, if you really do not know what you are doing, I highly recommend that you do not .
However, if you want, you can use a really nice library ( Azure Service Management through C # ), although we do have some problems using WCF.
Here is a brief description of how to do this (note: you need to include the management certificate as a resource in your code and deploy it to Azure):
private static bool IsStaging() { try { if (!CloudEnvironment.IsAvailable) return false; const string certName = "AzureManagement.pfx"; const string password = "Pa$$w0rd"; // load certificate var manifestResourceStream = typeof(ProjectContext).Assembly.GetManifestResourceStream(certName); if (manifestResourceStream == null) { // should we panic? return true; } var bytes = new byte[manifestResourceStream.Length]; manifestResourceStream.Read(bytes, 0, bytes.Length); var cert = new X509Certificate2(bytes, password); var serviceManagementChannel = Microsoft.Toolkit.WindowsAzure.ServiceManagement.ServiceManagementHelper. CreateServiceManagementChannel("WindowsAzureServiceManagement", cert); using (new OperationContextScope((IContextChannel)serviceManagementChannel)) { var hostedServices = serviceManagementChannel.ListHostedServices(WellKnownConfiguration.General.SubscriptionId); // because we don't know the name of the hosted service, we'll do something really wasteful // and iterate foreach (var hostedService in hostedServices) { var ad = serviceManagementChannel.GetHostedServiceWithDetails( WellKnownConfiguration.General.SubscriptionId, hostedService.ServiceName, true); var deployment = ad.Deployments.Where( x => x.PrivateID == Zebra.Framework.Azure.CloudEnvironment.CurrentRoleInstanceId). FirstOrDefault (); if (deployment != null) { return deployment.DeploymentSlot.ToLower().Equals("staging"); } } } return false; } catch (Exception e) { // if something went wrong, let not panic TraceManager.AzureFrameworkTraceSource.TraceData(System.Diagnostics.TraceEventType.Error, "Exception", e); return false; } }
source share