Azure App Service Application Settings being overriden

Steve Odai 6 Reputation points
2023-01-07T16:00:22.86+00:00

I am trying to load my appsettings.test.json file on a test API and I am having problems reading environment variables. Works fine locally but when I push it to the Azure App Service I keep getting pointed to my dev appsettings.json file.
I will attach my settings below and the API call results I used to verify this issue. Every other custom value works aside ASPNETCORE_ENVIRONMENT.
<h3>Azure App Service Application Settings</h3>
![knYLm.png][1]

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
6,956 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Udaiappa Ramachandran 726 Reputation points MVP
    2023-01-10T03:44:27.263+00:00

    Hello @Steve Odai

    I think that the valid environment variables are Development, Production, and Staging. For the value of "Test", you can add this to configuration --> appsettings or hardcode the file name 277714-image.png

    2 people found this answer helpful.
    0 comments No comments

  2. Steve Odai 6 Reputation points
    2023-01-10T09:53:47.78+00:00

    FYI, if anyone encounters this issue. My project was originally a .NET CORE 3.1 project, even after upgrading to 6 there were obviously still lingering files which wouldn't be cleared just because I targeted a newer framework.

    The culprit was my web.config file, it was overriding my ASPNETCORE_ENVIRONMENT env variable.

    &lt;environmentVariables&gt;
    &lt;environmentVariable name=&#34;ASPNETCORE_ENVIRONMENT&#34; value=&#34;Development&#34; /&gt;
    &lt;environmentVariable name=&#34;ASPNETCORE_HTTPS_PORT&#34; value=&#34;44364&#34; /&gt;
    &lt;environmentVariable name=&#34;COMPLUS_ForceENC&#34; value=&#34;1&#34; /&gt;
    &lt;/environmentVariables&gt;
    
    1 person found this answer helpful.
    0 comments No comments