private async Task <IDictionary <string, string> > GetConfigurationSettings(string scriptPath, Uri uri) { var settings = _secretsManager.GetSecrets(); settings.TryAdd(Constants.WebsiteHostname, uri.Authority); // Add our connection strings var connectionStrings = _secretsManager.GetConnectionStrings(); settings.AddRange(connectionStrings.ToDictionary(c => $"ConnectionStrings:{c.Name}", c => c.Value)); settings.TryAdd(EnvironmentSettingNames.AzureWebJobsScriptRoot, scriptPath); var environment = Environment .GetEnvironmentVariables() .Cast <DictionaryEntry>() .ToDictionary(k => k.Key.ToString(), v => v.Value.ToString()); await CheckNonOptionalSettings(settings.Union(environment), scriptPath, SkipAzureStorageCheck); // when running locally in CLI we want the host to run in debug mode // which optimizes host responsiveness settings.TryAdd(Constants.AzureFunctionsEnvorinmentEnvironmentVariable, "Development"); settings.TryAdd(Constants.AspNetCoreEnvironmentEnvironmentVariable, "Development"); return(settings); }
/// <summary> /// This method reads the secrets from local.settings.json and sets them /// AppSettings are set in environment variables, ConfigurationManager.AppSettings /// ConnectionStrings are only set in ConfigurationManager.ConnectionStrings /// /// It also sets up a FileSystemWatcher that kills the current running process /// when local.settings.json is updated. /// </summary> private async Task ReadSecrets(string scriptPath) { var secrets = _secretsManager.GetSecrets(); UpdateEnvironmentVariables(secrets); UpdateAppSettings(secrets); UpdateConnectionStrings(_secretsManager.GetConnectionStrings()); await CheckNonOptionalSettings(secrets, scriptPath); fsWatcher = new FileSystemWatcher(Path.GetDirectoryName(SecretsManager.AppSettingsFilePath), SecretsManager.AppSettingsFileName); fsWatcher.Changed += (s, e) => { Environment.Exit(ExitCodes.Success); }; fsWatcher.EnableRaisingEvents = true; }
/// <summary> /// This method reads the secrets from local.settings.json and sets them /// AppSettings are set in environment variables, ConfigurationManager.AppSettings /// ConnectionStrings are only set in ConfigurationManager.ConnectionStrings /// /// It also sets up a FileSystemWatcher that kills the current running process /// when local.settings.json is updated. /// </summary> private async Task ReadSecrets(string scriptPath, Uri uri) { var secrets = _secretsManager.GetSecrets(); var environment = Environment .GetEnvironmentVariables() .Cast <DictionaryEntry>() .ToDictionary(k => k.Key.ToString(), v => v.Value.ToString()); UpdateEnvironmentVariables(secrets, uri); UpdateAppSettings(secrets); UpdateConnectionStrings(_secretsManager.GetConnectionStrings()); await CheckNonOptionalSettings(secrets.Union(environment), scriptPath); fsWatcher = new FileSystemWatcher(Path.GetDirectoryName(SecretsManager.AppSettingsFilePath), SecretsManager.AppSettingsFileName); fsWatcher.Changed += (s, e) => { Environment.Exit(ExitCodes.Success); }; fsWatcher.EnableRaisingEvents = true; }
public override Task RunAsync() { ColoredConsole.WriteLine(TitleColor("App Settings:")); foreach (var pair in _secretsManager.GetSecrets()) { ColoredConsole .WriteLine($" -> {TitleColor("Name")}: {pair.Key}") .WriteLine($" {TitleColor("Value")}: {(ShowValues ? pair.Value : "*****")}") .WriteLine(); } ColoredConsole.WriteLine(TitleColor("Connection Strings:")); foreach (var pair in _secretsManager.GetConnectionStrings()) { ColoredConsole .WriteLine($" -> {TitleColor("Name")}: {pair.Key}") .WriteLine($" {TitleColor("Value")}: {(ShowValues ? pair.Value : "*****")}") .WriteLine(); } return(Task.CompletedTask); }