예제 #1
0
        private static async Task <EnvironmentResources> CreateEnvironmentResourcesAsync(OperationContext context, EnvironmentConfiguration configuration)
        {
            var azure = ExternalDependenciesFactory.CreateAzureClient(
                configuration.AzureTenantId,
                configuration.AzureSubscriptionId,
                configuration.AzureAppId,
                configuration.AzureAppKey).ThrowIfFailure();

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

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

            var kustoClient = ExternalDependenciesFactory.CreateKustoQueryClient(
                configuration.KustoClusterUrl,
                configuration.AzureTenantId,
                configuration.AzureAppId,
                configuration.AzureAppKey).ThrowIfFailure();

            context.Token.ThrowIfCancellationRequested();
            return(new EnvironmentResources(azure, monitorManagementClient, redisCaches, kustoClient));
        }
예제 #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));
        }