public IConfigurationProvider Build(IConfigurationBuilder builder)
        {
            IConfigurationProvider provider = null;

            try
            {
                AzureAppConfigurationOptions options = _optionsProvider();
                ConfigurationClient          client;

                if (options.Client != null)
                {
                    client = options.Client;
                }
                else if (!string.IsNullOrWhiteSpace(options.ConnectionString))
                {
                    client = _configurationClientFactory.CreateConfigurationClient(options.ConnectionString, options.ClientOptions);
                }
                else if (options.Endpoint != null && options.Credential != null)
                {
                    client = _configurationClientFactory.CreateConfigurationClient(options.Endpoint, options.Credential, options.ClientOptions);
                }
                else
                {
                    throw new ArgumentException($"Please call {nameof(AzureAppConfigurationOptions)}.{nameof(AzureAppConfigurationOptions.Connect)} to specify how to connect to Azure App Configuration.");
                }

                provider = new AzureAppConfigurationProvider(client, options, _optional);
            }
            catch (InvalidOperationException e)
            {
                if (!_optional)
                {
                    throw new ArgumentException(e.Message, e);
                }
            }

            return(provider ?? new EmptyConfigurationProvider());
        }
Example #2
0
 public void SetProvider(AzureAppConfigurationProvider provider)
 {
     _provider = provider ?? throw new ArgumentNullException(nameof(provider));
     AppConfigurationEndpoint = _provider.AppConfigurationEndpoint;
 }
 public void SetProvider(AzureAppConfigurationProvider provider)
 {
     _provider = provider;
 }