コード例 #1
0
        public AzureSessionService(IAzureSessionOptions azureSessionOptions = null, IHttpClientFactory httpClientFactory = null)
        {
            this.azureSessionOptions = azureSessionOptions ?? AzureSessionOptions.Default;
            this.httpClientFactory   = httpClientFactory ?? new DefaultHttpClientFactory();

            credentials = new Lazy <AzureCredentials>(() => InitCredentials(), LazyThreadSafetyMode.PublicationOnly);
            session     = new Lazy <AZFluent.Azure.IAuthenticated>(() => InitSession(), LazyThreadSafetyMode.PublicationOnly);
        }
コード例 #2
0
        public AzureSessionFactory(IAzureSessionOptions azureSessionOptions)
        {
            this.azureSessionOptions = azureSessionOptions ?? throw new ArgumentNullException(nameof(azureSessionOptions));

            session = new Lazy <AZFluent.Azure.IAuthenticated>(() =>
            {
                var credentials = new RMFluent.Authentication.AzureCredentialsFactory()
                                  .FromServicePrincipal(azureSessionOptions.ClientId, azureSessionOptions.ClientSecret, azureSessionOptions.TenantId, RMFluent.AzureEnvironment.AzureGlobalCloud);

                return(AZFluent.Azure
                       .Configure()
                       .Authenticate(credentials));
            });
        }
コード例 #3
0
 public AzureSessionService(IAzureSessionOptions azureSessionOptions = null, IHttpClientFactory httpClientFactory = null)
 {
     this.azureSessionOptions = azureSessionOptions ?? AzureSessionOptions.Default;
     this.httpClientFactory   = httpClientFactory ?? new DefaultHttpClientFactory();
 }
コード例 #4
0
 public static Task <string> AcquireTokenAsync(AzureEndpoint azureEndpoint = AzureEndpoint.ResourceManagerEndpoint, IAzureSessionOptions azureSessionOptions = null, IHttpClientFactory httpClientFactory = null)
 => new AzureSessionService(azureSessionOptions, httpClientFactory).AcquireTokenAsync(azureEndpoint);