コード例 #1
0
        /// <inheritdoc />
        public void Configure(IWebHostBuilder builder)
        {
            var azureServiceTokenProvider = new AzureServiceTokenProvider();
            var authenticationCallback    = new KeyVaultClient.AuthenticationCallback(azureServiceTokenProvider.KeyVaultTokenCallback);
            var keyVaultClient            = new KeyVaultClient(authenticationCallback);

            var baseConfiguration = HostingStartupConfigurationExtensions.GetBaseConfiguration();

            builder.ConfigureServices((context, collection) =>
            {
                var configuration = new ConfigurationBuilder()
                                    .AddConfiguration(baseConfiguration)
                                    .AddConfiguration(context.Configuration)
                                    .Build();

                if (configuration.IsEnabled(HostingStartupName, DataProtectionFeatureName) &&
                    configuration.TryGetOption(HostingStartupName, DataProtectionKeyName, out var protectionKey))
                {
                    AddDataProtection(collection, keyVaultClient, protectionKey);
                }
            });

            if (baseConfiguration.IsEnabled(HostingStartupName, ConfigurationFeatureName) &&
                baseConfiguration.TryGetOption(HostingStartupName, ConfigurationVaultName, out var vault))
            {
                builder.ConfigureAppConfiguration((context, configurationBuilder) =>
                {
                    AddConfiguration(configurationBuilder, keyVaultClient, vault);
                });
            }
        }
コード例 #2
0
        /// <summary>
        /// Calls UseAzureAppServices
        /// </summary>
        /// <param name="builder"></param>
        public void Configure(IWebHostBuilder builder)
        {
            var baseConfiguration = HostingStartupConfigurationExtensions.GetBaseConfiguration();

            if (baseConfiguration.IsEnabled(HostingStartupName, DiagnosticsFeatureName))
            {
                builder.UseAzureAppServices();
            }
        }