The description says
> When AZURE_FUNCTIONS_ENVIRONMENT isn't set, it defaults to Production.
This may be true in Azure, but it is not true for development in VS. It defaults to "Development".
⚠Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
Hi @MisinformedDNA - Thank you for your feedback! We will review and update as appropriate.
Hi @MisinformedDNA - We're making an update to the statement to read as follows:
When
AZURE_FUNCTIONS_ENVIRONMENT
isn't set, it defaults toDevelopment
on a local environment andProduction
on Azure.
@MisinformedDNA We will now proceed to close this thread. If there are further questions regarding this matter, please reopen it and we will gladly continue the discussion.
I just created a new Function app in VS and if I add the variable to local.settings.json
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME": "dotnet",
"AZURE_FUNCTIONS_ENVIRONMENT": "Staging"
}
}
And run locally, then I get the error
Azure Functions Core Tools (2.7.1434 Commit hash: eac7c2888f315da0f2b51831b47f134330b501fd)
Function Runtime Version: 2.0.12555.0
An item with the same key has already been added. Key: AZURE_FUNCTIONS_ENVIRONMENT
How do I set AZURE_FUNCTIONS_ENVIRONMENT
when testing in VS?
I just created a new Function app in VS and if I add the variable to local.settings.json
{ "IsEncrypted": false, "Values": { "AzureWebJobsStorage": "UseDevelopmentStorage=true", "FUNCTIONS_WORKER_RUNTIME": "dotnet", "AZURE_FUNCTIONS_ENVIRONMENT": "Staging" } }
And run locally, then I get the error
Azure Functions Core Tools (2.7.1434 Commit hash: eac7c2888f315da0f2b51831b47f134330b501fd)
Function Runtime Version: 2.0.12555.0
An item with the same key has already been added. Key: AZURE_FUNCTIONS_ENVIRONMENTHow do I set
AZURE_FUNCTIONS_ENVIRONMENT
when testing in VS?
I also experience this. Both on .net core 2.1 and .net core 3.0:
Azure Functions Core Tools (2.7.1846 Commit hash: 458c671341fda1c52bd46e1aa8943cb26e467830)
Function Runtime Version: 2.0.12858.0
An item with the same key has already been added. Key: AZURE_FUNCTIONS_ENVIRONMENT
I can still set ASPNETCORE_ENVIRONMENT on local development machine, and it reflects the given environment when starting up the Azure Functions runtime. I don't know if this reflects in same way in Azure, can someone confirm this? Can I set the ASPNETCORE_ENVIRONMENT in Azure and expect the hosting to be resolved properly, or do I need to make some code to automatically not add the AZURE_FUNCTIONS_ENVIRONMENT when on local development?
Most helpful comment
I also experience this. Both on .net core 2.1 and .net core 3.0:
I can still set ASPNETCORE_ENVIRONMENT on local development machine, and it reflects the given environment when starting up the Azure Functions runtime. I don't know if this reflects in same way in Azure, can someone confirm this? Can I set the ASPNETCORE_ENVIRONMENT in Azure and expect the hosting to be resolved properly, or do I need to make some code to automatically not add the AZURE_FUNCTIONS_ENVIRONMENT when on local development?