ANCM not reading “ASPNETCORE_ENVIRONMENT” variable from local environment.

This post has been republished via RSS; it originally appeared at: IIS Support Blog articles.

After upgrading the core application to core 3.1 version, application is not able to read the “ASPNETCORE_ENVIRONMENT” variable from local environment and getting defaulted to web.config values.


ASPNETCORE_ENVIRONMENT value is set as Development in Web.config.





ASPNETCORE_ENVIRONMENT value is set as Production in local environment of Azure App Service application setting.





ANCM is Preferring value set in Web.config over the local environment variable in Azure App service application setting.







We need to add a switch “ANCM_PREFER_ENVIRONMENT_VARIABLES” and set as “true”  to allow ANCM to prefer the local environment over the Web.config values. Below is the screenshot of app service app settings.




If the switch is added in both Web.config and local environment and both of them are set to "true" then web.config "ASPNETCORE_ENVIRONMENT" will take precedence.


After setting “ANCM_PREFER_ENVIRONMENT_VARIABLES” as “true” in App service App settings, ANCM is preferring the local environment variable "ASPNETCORE_ENVIRONMENT" which is set to production .




For more information about these changes, please refer below Github issues.

REMEMBER: these articles are REPUBLISHED. Your best bet to get a reply is to follow the link at the top of the post to the ORIGINAL post! BUT you're more than welcome to start discussions here:

This site uses Akismet to reduce spam. Learn how your comment data is processed.