Azure / Azure/azure-functions-host

AZURE_FUNCTIONS_ENVIRONMENT value not reflect on Windows Plan

Open
#6,978 1 comment 0 reactions 0 assignees View on GitHub
bug
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
![スクリーンショット 2020-12-10 225918](https://user-images.githubusercontent.com/24888431/101781603-5def3880-3b3b-11eb-8197-a46adaa3b387.png)

3. Check the result which type return bool variable in Azure Functions monitor.
![image](https://user-images.githubusercontent.com/24888431/101781849-ab6ba580-3b3b-11eb-92c9-77f2eb71bd1d.png)

#### 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`.

![スクリーンショット 2020-12-10 224500](https://user-images.githubusercontent.com/24888431/101780077-6777a100-3b39-11eb-8f43-2eba28bd20fd.png)

#### 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

Open the contributing 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.