public AzureBaseManager(IAzureCloudAuthenticationInfo authInfo) { this.AuthInfo = authInfo; switch (this.AuthInfo.AuthenticationMode) { case CloudAuthenticationMode.AccessToken: Microsoft.Rest.TokenCredentials tokenCredentials = new Microsoft.Rest.TokenCredentials(this.AuthInfo.AzureAccessToken); this.ServiceCredentials = tokenCredentials; break; case CloudAuthenticationMode.Certificate: X509Certificate2 cert = new X509Certificate2(this.AuthInfo.CertificateBytes, this.AuthInfo.PfxCertificatePassword, X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.PersistKeySet | X509KeyStorageFlags.Exportable); Microsoft.Rest.CertificateCredentials certificateCredentials = new Microsoft.Rest.CertificateCredentials(cert); this.ServiceCredentials = certificateCredentials; break; case CloudAuthenticationMode.PublishingProfile: byte[] managementCertificateBytes = Convert.FromBase64String(this.AuthInfo.ManagementCertificate); X509Certificate2 publishingCert = new X509Certificate2(managementCertificateBytes, string.Empty, X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.PersistKeySet | X509KeyStorageFlags.Exportable); Microsoft.Rest.CertificateCredentials publishingCredentials = new CertificateCredentials(publishingCert); this.ServiceCredentials = publishingCredentials; break; } }
public AzureVirtualMachinesManager(IAzureCloudAuthenticationInfo authInfo) : base(authInfo) { this._computeManagementClient = new Microsoft.Azure.Management.Compute.ComputeManagementClient(base.ServiceCredentials); this._computeManagementClient.SubscriptionId = base.AuthInfo.SubscriptionId; }