Azure-docs: Description of AZURE_FUNCTIONS_ENVIRONMENT is inaccurate

Created on 29 Jul 2019  Â·  5Comments  Â·  Source: MicrosoftDocs/azure-docs

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".


Document Details

⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Pri1 azure-functionsvc cxp doc-enhancement triaged

Most helpful comment

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

All 5 comments

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 to Development on a local environment and Production 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_ENVIRONMENT

How 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?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

DeepPuddles picture DeepPuddles  Â·  3Comments

AronT-TLV picture AronT-TLV  Â·  3Comments

monteledwards picture monteledwards  Â·  3Comments

JamesDLD picture JamesDLD  Â·  3Comments

ianpowell2017 picture ianpowell2017  Â·  3Comments