Azure / Azure/azure-functions-host
AZURE_FUNCTIONS_ENVIRONMENT value not reflect on Windows Plan
- Dominant language
- C#
- Stars
- 2k
- Forks
- 482
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 38
Description
#### AZURE_FUNCTIONS_ENVIRONMENT value not reflect in Windows Plan
I create code that call IHostEnvironment interface IsDevelopment method for switching Development and Production environment when use the following the Environment as a application setting in Azure Functions on Windows consumption, AppService, Premium Plan.
https://docs.microsoft.com/en-us/azure/azure-functions/functions-app-settings#azure_functions_environment
This environment default value in Azure Functions is `True` when call IsDevelopment method. But even set AZURE_FUNCTIONS_ENVIRONMENT=Production, Azure Functions return to `True`.
~~I change to Windows consumption plan to Premier Plan. Then IsDevelopment method returned to `False`.~~
I created new App Service Plan and Premium Plan. Deploy code to each app service plan and set AZURE_FUNCTIONS_ENVIRONMENT=Production. but It was not displayed `False`.
#### Investigative information
Please provide the following:
- Timestamp: ongoing ~
- Function App version: 3.0.14916.0
- Function App name: ishostenvironment
- Function name(s) (as appropriate): Function 1
- Invocation ID: All
- Region: Japan East
#### Repro steps
1. Deploy to Azure Functions bellow source code.
2. Set the application setting

3. Check the result which type return bool variable in Azure Functions monitor.

#### Expected behavior
- IsDevelopment() value is `False`, when set AZURE_FUNCTIONS_ENVIRONMENT=Production
#### Actual behavior
- Even set AZURE_FUNCTIONS_ENVIRONMENT=Production but IsDevelopment() value is `True`.

#### Related information
* Programming language used : C#
* Bindings used : Timer
```csharp
public class Function1
{
private readonly IHostEnvironment _hostEnvironment;
private readonly IConfiguration _configuration;
public Function1(IHostEnvironment hostEnvironment, IConfiguration configuration)
{
_hostEnvironment = hostEnvironment ?? throw new ArgumentNullException(nameof(hostEnvironment));
_configuration = configuration ?? throw new ArgumentNullException(nameof(configuration));
}
[FunctionName("Function1")]
public void Run([TimerTrigger("0 */1 * * * *")] TimerInfo myTimer, ILogger log)
{
log.LogInformation($"C# Timer trigger function executed at: {DateTime.Now}");
log.LogInformation($"_hostEnvironment.IsDevelopment(): {_hostEnvironment.IsDevelopment()}");
}
}
```
Contributor guide
Research direction
Start with the reported Function1 reproduction and the mapping from AZURE_FUNCTIONS_ENVIRONMENT to IHostEnvironment.IsDevelopment() on Windows consumption, App Service, and Premium plans. Verify the behavior using the supplied application setting and timer-triggered function; done when Production consistently produces false across the affected plans.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure, csharp
- Domain
- backend, cloud
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100