I have an ASP.NET Core website running from Kestrel. It is deployed to Azure App Service in production and another as staging.
I like to configure staging as “production-like” so I set
ASPNETCORE_ENVIRONMENTNAME = Production in the Configuration blade of the App Service in the Azure portal. I could see from logs that the code was seeing the environment name as
It turns out
<environmentVariable name="ASPNETCORE_ENVIRONMENTNAME" value="staging" /> is set in the
web.config that’s on the Azure instance!!
Now, I don’t have this set in the
web.config or any transforms in my codebase, and I don’t use the
web.config, in fact I want nothing to do with it or IIS.
My site is deployed via Azure Pipelines. I use
environmentName as a build time variable but the YAML only uses it once, to concatenate some text to make up the resource group name.
I then ran
dotnet deploy using the same command line as Azure Pipelines runs, but the
web.config it writes into the final publish output folder doesn’t contain the offending line either.
It was only a few weeks ago I rebuilt and redeployed all my Azure resources. It was all clean, and it’s all scripted.
Where on Earth has it come from??!
I’m worried that if I remove it, one day, it’ll magically just reappear. It smells very much like someone at Microsoft thought this automagic was a good idea.
Mind you, I’ve tried to remove it using the App Service Editor and Kudu but I’m not allowed!!
Your app is currently in read only mode because you are running from a package file. To make any changes, please update the content in your zip file and WEBSITE_RUN_FROM_PACKAGE app setting.
So if I’m not setting it, and I’m not allowed to change it, what do I do??
I’ve downloaded the artifacts from Pipelines and the web.config has the setting in place.
The command run, according to the Pipelines log, was this.
dotnet publish --configuration Release --output D:a1s/dotnet-publish-output
But when I run that myself, on my machine, it does not meddle with my web.config.
Read more here: Source link