Esempio n. 1
0
        public static (IAzure, IResourceManager) Authenticate(string subscriptionId)
        {
            string version = Assembly.GetEntryAssembly()?
                             .GetCustomAttribute <AssemblyInformationalVersionAttribute>()?
                             .InformationalVersion ?? "1.0.0";

            var tokenCredentials = new TokenCredentials(new AzureCredentialsTokenProvider(TokenProvider));
            var credentials      = new AzureCredentials(tokenCredentials, null, MsftAdTenantId, AzureEnvironment.AzureGlobalCloud);

            HttpLoggingDelegatingHandler.Level logLevel = HttpLoggingDelegatingHandler.Level.Headers;
            var retryPolicy = new RetryPolicy(new DefaultTransientErrorDetectionStrategy(), 5);
            var programName = "DncEng Service Fabric Cluster Creator";

            return(Azure.Management.Fluent.Azure.Configure()
                   .WithLogLevel(logLevel)
                   .WithRetryPolicy(retryPolicy)
                   .WithUserAgent(programName, version)
                   .Authenticate(credentials)
                   .WithSubscription(subscriptionId),
                   ResourceManager.Configure()
                   .WithLogLevel(logLevel)
                   .WithRetryPolicy(retryPolicy)
                   .WithUserAgent(programName, version)
                   .Authenticate(credentials)
                   .WithSubscription(subscriptionId));
        }
Esempio n. 2
0
 public IBuildable WithLogLevel(HttpLoggingDelegatingHandler.Level level)
 {
     if (loggingDelegatingHandler == null)
     {
         loggingDelegatingHandler = new HttpLoggingDelegatingHandler();
         WithDelegatingHandler(loggingDelegatingHandler);
     }
     loggingDelegatingHandler.LogLevel = level;
     return(this);
 }
Esempio n. 3
0
 public T WithLogLevel(HttpLoggingDelegatingHandler.Level level)
 {
     restClientBuilder.WithLogLevel(level);
     return(this as T);
 }
        public async Task RuntimeConfiguration_HasConfiguredAzureMonitorLoggingInformationLevel_UsesConfigured(HttpLoggingDelegatingHandler.Level informationLevel)
        {
            // Arrange
            var configuration = await RuntimeConfigurationGenerator.WithServerConfiguration()
                                .WithAzureMonitorLogging(informationLevel: informationLevel)
                                .GenerateAsync();

            // Act
            var runtimeConfiguration = configuration.Get <ScraperRuntimeConfiguration>();

            // Assert
            Assert.NotNull(runtimeConfiguration);
            Assert.NotNull(runtimeConfiguration.AzureMonitor);
            Assert.NotNull(runtimeConfiguration.AzureMonitor.Logging);
            Assert.Equal(informationLevel, runtimeConfiguration.AzureMonitor.Logging.InformationLevel);
        }
        public RuntimeConfigurationGenerator WithAzureMonitorLogging(bool isEnabled = true, HttpLoggingDelegatingHandler.Level informationLevel = HttpLoggingDelegatingHandler.Level.Headers)
        {
            if (_runtimeConfiguration.AzureMonitor == null)
            {
                _runtimeConfiguration.AzureMonitor = new AzureMonitorConfiguration();
            }

            _runtimeConfiguration.AzureMonitor.Logging = new AzureMonitorLoggingConfiguration
            {
                IsEnabled        = isEnabled,
                InformationLevel = informationLevel
            };

            return(this);
        }
Esempio n. 6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ApimRestClient"/> class.
 /// </summary>
 /// <param name="tenantId">Id of the Tenant to use for authentication - use null for the default tenant.</param>
 /// <param name="environment">Azure environment to use.</param>
 /// <param name="loggingLevel">Logging level to use.</param>
 public AzureRestClient(string tenantId, AzureEnvironment environment, HttpLoggingDelegatingHandler.Level loggingLevel)
 {
     _tenantId     = tenantId;
     _environment  = environment;
     _loggingLevel = loggingLevel;
 }