protected override void Load(ContainerBuilder builder) { var settings = new CloudConfigurationSettings { DataConnectionString = DataConnectionString, SelfManagementSubscriptionId = SelfManagementSubscriptionId, SelfManagementCertificateThumbprint = SelfManagementCertificateThumbprint }; if (string.IsNullOrEmpty(settings.DataConnectionString)) { settings = CloudConfigurationSettings.LoadFromRoleEnvironment(); } // Only register storage components if the storage credentials are OK // This will cause exceptions to be thrown quite soon, but this way // the roles' OnStart() method returns correctly, allowing the web role // to display a warning to the user (the worker is recycled indefinitely // as Run() throws almost immediately) if (settings != null && !string.IsNullOrEmpty(settings.DataConnectionString)) { builder.RegisterInstance(settings); } }
public EnvironmentAdapter(CloudConfigurationSettings settings, ILog log, IProvisioningObserver provisioningObserver = null) { _log = log; // try get settings and certificate if (!IsAvailable) { _log.TryWarnFormat("Provisioning: RoleEnvironment not available on worker {0}.", _hostName.Value); return; } var currentDeploymentPrivateId = RoleEnvironment.DeploymentId; X509Certificate2 certificate = null; if (!String.IsNullOrWhiteSpace(settings.SelfManagementCertificateThumbprint)) { certificate = GetCertificate(settings.SelfManagementCertificateThumbprint); } // early evaluate management status for intrinsic fault states, to skip further processing if (currentDeploymentPrivateId == null || certificate == null || string.IsNullOrWhiteSpace(settings.SelfManagementSubscriptionId)) { _log.TryDebug("Provisioning: Not available because either the certificate or the subscription was not provided correctly."); return; } // detect dev fabric if (currentDeploymentPrivateId.StartsWith("deployment(")) { _log.TryDebug("Provisioning: Not available in dev fabric instance."); return; } // ok _provisioning = new AzureProvisioning(settings.SelfManagementSubscriptionId, certificate, provisioningObserver); _currentDeployment = new AzureCurrentDeployment(currentDeploymentPrivateId, settings.SelfManagementSubscriptionId, certificate, provisioningObserver); }