0
votes

I'm using dot net core 3.0.1, for some reason I'm finding it really hard to work out how to utilize my appsettings.production.json when deploying using azure devops pipelines. My pipeline is as follows; Restore > Build > Package > Publish Artefact > Azure App Service Deploy The application is hosted fine but I cant see where/how I tell it to use/apply the production transform.

1
Well, do you use env-vars? I'm not familiar with Az App Svc - only docker/kubernetes where env-vars are very common. In docker, you always set the env-var in the build step.Henkolicious
yep, ended up being an env var "ASPNETCORE_ENVIRONMENT", I wrongly assumed it was a transform approach like all previous ms frameworks so my search's where always offTom Riley

1 Answers

0
votes

Dot net core how do I utilise appsettings.[envname].json when deploying via azure devops?

There is difference between Web Deploy/Visual Studio and Deploy Azure App Service in Azure devops publish task.

In order to use/apply the production transform during the Azure devops release, you will need to add variables to the release task and pass into the task the json file in question for variable substitution.

When in "Deploy Azure App Service" release task you should see a "File Transforms and Variable Substitution" section. In here you will supply the path to the json file you want to swap variable values:

enter image description here

Then you can add the json property you want to modify as a variable. In my case the connection string. Which will look like the following:

enter image description here

Check the document File transforms and variable substitution reference for some more details.

Hope this helps.