Exemplo n.º 1
0
 public AzureHelper(IX509Helper _X509Helper)
 {
     X509Helper          = _X509Helper as X509Helper;
     VirtualMashinesList = new VMList(this);
     X509Helper.RotateCertificate();
     Task.Run(() => UpdateAllVirtualMashinesAsync());
     Task.Run(() => StartVirtualMashinesAsync());
     Task.Run(() => StopVirtualMashinesAsync());
     AzureHelperService.AzureHelper = this;
 }
Exemplo n.º 2
0
        /// <summary>
        /// GetAzureConnection
        /// </summary>
        /// <param name="_clientId"></param>
        /// <param name="_tenantId"></param>
        /// <returns></returns>
        private IAzure GetAzureConnection(string _clientId, string _tenantId, string _subscriptionId, bool _withoutSubscription = false)
        {
            IAzure azure;
            var    creds = new AzureCredentialsFactory().FromServicePrincipal(_clientId, X509Helper.GetRootCertificate(), _tenantId, AzureEnvironment.AzureGlobalCloud);

            if (_withoutSubscription)
            {
                azure = Azure
                        .Configure()
                        .WithLogLevel(HttpLoggingDelegatingHandler.Level.Basic)
                        .Authenticate(creds)
                        .WithDefaultSubscription();
            }
            else
            {
                azure = Azure
                        .Configure()
                        .WithLogLevel(HttpLoggingDelegatingHandler.Level.Basic)
                        .Authenticate(creds)
                        .WithSubscription(_subscriptionId);
            }

            return(azure);
        }
Exemplo n.º 3
0
 public X509Certificate2 GetCertificate()
 {
     return(X509Helper.GetPublicKeyCertificate());
 }