Adding environment support (#383)
This commit is contained in:
Родитель
427a8994af
Коммит
ca0b972cf1
|
@ -13,6 +13,7 @@ namespace Cosmos.Samples.AzureFunctions
|
|||
private static IConfigurationRoot configuration = new ConfigurationBuilder()
|
||||
.SetBasePath(Environment.CurrentDirectory)
|
||||
.AddJsonFile("AppSettings.json", optional: true, reloadOnChange: true)
|
||||
.AddEnvironmentVariables()
|
||||
.Build();
|
||||
|
||||
public override void Configure(IFunctionsHostBuilder builder)
|
||||
|
@ -23,13 +24,13 @@ namespace Cosmos.Samples.AzureFunctions
|
|||
string endpoint = configuration["EndPointUrl"];
|
||||
if (string.IsNullOrEmpty(endpoint))
|
||||
{
|
||||
throw new ArgumentNullException("Please specify a valid endpoint in the appSettings.json");
|
||||
throw new ArgumentNullException("Please specify a valid endpoint in the appSettings.json file or your Azure Functions Settings.");
|
||||
}
|
||||
|
||||
string authKey = configuration["AuthorizationKey"];
|
||||
if (string.IsNullOrEmpty(authKey) || string.Equals(authKey, "Super secret key"))
|
||||
{
|
||||
throw new ArgumentException("Please specify a valid AuthorizationKey in the appSettings.json");
|
||||
throw new ArgumentException("Please specify a valid AuthorizationKey in the appSettings.json file or your Azure Functions Settings.");
|
||||
}
|
||||
|
||||
CosmosClientBuilder configurationBuilder = new CosmosClientBuilder(endpoint, authKey);
|
||||
|
|
Загрузка…
Ссылка в новой задаче