Ejemplo n.º 1
0
        private static async Task <EnvironmentResources> CreateEnvironmentResourcesAsync(OperationContext context, EnvironmentConfiguration configuration)
        {
            var azure = ExternalDependenciesFactory.CreateAzureClient(configuration.AzureCredentials).ThrowIfFailure();
            var monitorManagementClient = await ExternalDependenciesFactory.CreateAzureMetricsClientAsync(configuration.AzureCredentials).ThrowIfFailureAsync();

            var redisCaches =
                (await azure
                 .RedisCaches
                 .ListAsync(cancellationToken: context.Token))
                .ToDictionary(cache => cache.Name, cache => cache);

            var kustoClient = ExternalDependenciesFactory.CreateKustoQueryClient(configuration.KustoCredentials).ThrowIfFailure();

            context.Token.ThrowIfCancellationRequested();
            return(new EnvironmentResources(azure, monitorManagementClient, redisCaches, kustoClient));
        }
Ejemplo n.º 2
0
        private static async Task <EnvironmentResources> CreateEnvironmentResourcesAsync(Configuration configuration, EnvironmentConfiguration environmentConfiguration)
        {
            var azure = ExternalDependenciesFactory.CreateAzureClient(
                configuration.AzureTenantId,
                environmentConfiguration.AzureSubscriptionId,
                configuration.AzureAppId,
                configuration.AzureAppKey).ThrowIfFailure();

            var monitorManagementClient = await ExternalDependenciesFactory.CreateAzureMetricsClientAsync(
                configuration.AzureTenantId,
                environmentConfiguration.AzureSubscriptionId,
                configuration.AzureAppId,
                configuration.AzureAppKey).ThrowIfFailureAsync();

            var redisCaches = (await azure.RedisCaches.ListAsync()).ToDictionary(cache => cache.Name, cache => cache);

            return(new EnvironmentResources(azure, monitorManagementClient, redisCaches));
        }