Azure / Azure/azure-functions-host

IConfiguration lookups in WebHost are case sensitive for Environment Variables in Linux

Open
#10,864 0 comments 0 reactions 0 assignees View on GitHub
Needs: Triage (Functions)
Dominant language
C#
Stars
2k
Forks
482
Avg merge
2d 10h
Merged PRs (30d)
36

Description

### Problem statement

Because these lookups are case-sensitive on Linux, value resolution through this configuration source can fail when a setting is stored under a different casing than the one the host queries. For example, the host queries `AzureWebJobsStorage__AccountName` while the value was set as `AzureWebJobsStorage__accountName`.

In practice, this was not observable because this WebHost configuration source is normally combined with the active host configuration (`ActiveHostConfigurationSource`), which exposes its values through a case-insensitive (`OrdinalIgnoreCase`) dictionary. Once the active host configuration is loaded and merged, lookups resolve regardless of casing.

A recent platform change altered the order/timing in which some of these settings are accessed during specialization, so that they can now be read before the active host configuration has loaded and merged. When that happens, resolution falls solely to this case-sensitive source, and a setting stored under a different casing fails to resolve even though it exists. A concrete example is `HostAzureBlobStorageProvider` failing to resolve the storage account during specialization, which prevents the corresponding service client from being constructed.

### Underlying behavior
In our attempt to override the default environment variables configuration source and avoid certain caching issues (particularly affecting specialized apps), we've introduced a custom configuration source:

https://github.com/Azure/azure-functions-host/blob/26b6c418389b22806f949c95669dd80bc21abd4d/src/WebJobs.Script.WebHost/Program.cs#L62-L69

However, **one side effect** of this custom implementation is that lookups for environment variable keys become **case sensitive** on operating systems that inherently treat environment variables as case sensitive (e.g., Linux)

https://github.com/Azure/azure-functions-host/blob/26b6c418389b22806f949c95669dd80bc21abd4d/src/WebJobs.Script/Config/ScriptEnvironmentVariablesConfigurationSource.cs#L27-L32

This configuration source is also used in the [ScriptSettingsManager](https://github.com/Azure/azure-functions-host/blob/26b6c418389b22806f949c95669dd80bc21abd4d/src/WebJobs.Script/Config/ScriptSettingsManager.cs)

Contributor guide

Open the contributing guide

Research direction

Start with the custom source registration in src/WebJobs.Script.WebHost/Program.cs and the implementation in src/WebJobs.Script/Config/ScriptEnvironmentVariablesConfigurationSource.cs. Read how ScriptSettingsManager uses this source, then trace HostAzureBlobStorageProvider during specialization. Done means differently cased environment-variable keys resolve before ActiveHostConfigurationSource is loaded and the storage client can be constructed.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, csharp
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.