Esempio n. 1
0
 public AzureUpdater(AzureDiscoveryInfo discoveryInfo)
 {
     _info = discoveryInfo;
     _provisioning = new AzureProvisioning(
         CloudConfiguration.SubscriptionId,
         CloudConfiguration.GetManagementCertificate());
 }
Esempio n. 2
0
        /// <summary>IoC constructor.</summary>
        public CloudProvisioning(ICloudConfigurationSettings settings, ILog log, ICloudProvisioningObserver provisioningObserver = null)
        {
            _log = log;

            // try get settings and certificate
            if (!CloudEnvironment.IsAvailable)
            {
                _log.WarnFormat("Provisioning: RoleEnvironment not available on worker {0}.", CloudEnvironment.PartitionKey);
                return;
            }

            var currentDeploymentPrivateId = CloudEnvironment.AzureDeploymentId;
            Maybe<X509Certificate2> certificate = Maybe<X509Certificate2>.Empty;
            if (!String.IsNullOrWhiteSpace(settings.SelfManagementCertificateThumbprint))
            {
                certificate = CloudEnvironment.GetCertificate(settings.SelfManagementCertificateThumbprint);
            }

            // early evaluate management status for intrinsic fault states, to skip further processing
            if (!currentDeploymentPrivateId.HasValue || !certificate.HasValue || string.IsNullOrWhiteSpace(settings.SelfManagementSubscriptionId))
            {
                _log.DebugFormat("Provisioning: Not available because either the certificate or the subscription was not provided correctly.");
                return;
            }

            // detect dev fabric
            if (currentDeploymentPrivateId.Value.StartsWith("deployment("))
            {
                _log.DebugFormat("Provisioning: Not available in dev fabric instance '{0}'.", CloudEnvironment.AzureCurrentInstanceId.GetValue("N/A"));
                return;
            }

            // ok
            _provisioning = new AzureProvisioning(settings.SelfManagementSubscriptionId, certificate.Value, provisioningObserver);
            _currentDeployment = new AzureCurrentDeployment(currentDeploymentPrivateId.Value, settings.SelfManagementSubscriptionId, certificate.Value, provisioningObserver);
        }