diff --git a/src/libraries/Microsoft.Extensions.Configuration.EnvironmentVariables/src/EnvironmentVariablesConfigurationProvider.cs b/src/libraries/Microsoft.Extensions.Configuration.EnvironmentVariables/src/EnvironmentVariablesConfigurationProvider.cs index 409894d3c891f..35129bc1dcd5c 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.EnvironmentVariables/src/EnvironmentVariablesConfigurationProvider.cs +++ b/src/libraries/Microsoft.Extensions.Configuration.EnvironmentVariables/src/EnvironmentVariablesConfigurationProvider.cs @@ -71,7 +71,7 @@ private static string NormalizeKey(string key) return key.Replace("__", ConfigurationPath.KeyDelimiter); } - private static IEnumerable AzureEnvToAppEnv(DictionaryEntry entry, string envPrefix = default) + private static IEnumerable AzureEnvToAppEnv(DictionaryEntry entry, string envPrefix) { string key = (string)entry.Key; string prefix = string.Empty; @@ -100,7 +100,7 @@ private static IEnumerable AzureEnvToAppEnv(DictionaryEntry ent { // This prevents the prefix from being normalized. // We can also do a fast path branch, I guess? No point in reallocating if the prefix is empty. - entry.Key = !string.IsNullOrEmpty(envPrefix) + entry.Key = envPrefix != string.Empty ? envPrefix + NormalizeKey(key.Substring(envPrefix.Length)) : NormalizeKey(key);