In the Azure App Service deploy task I specify the JSON variable substitution
as **/appsettings.json
and I can see in the log that the substitutions were made. However, every-so-often the appsettings.json
containing the substituted variable values is not copied as it not seen as changed. This results in the original templated appsettings.json
file being deployed and that causes the App Service to not start up correctly. Oddly enough, it seems to occur most often when the release is automatically triggered. When run manually it seems to copy the file.
It would’ve been nice to be able to simply perform a replace on a templated appsettings.json
file and then copy that to the App Service but I have not been able to find any way to do that… perhaps it isn’t possible.
If there is another way that would be easier to get environment-specific appsettings.json
files deployed to an App Service that would be great.
In the meantime, it would be first prize if the substituted file is always deployed.
There is a -useCheckSum
argument provided to the task if that makes any difference.
2
Answers
I was on a call with Microsoft support and the engineer suggested I use a FileTransform task prior to invoking the Azure App Service deploy task and remove substitutions from the deploy task altogether.
That did the trick.
Since the file transform task effectively replaces the
appsettings.json
in thezip
file with the one containing the substituted values that is what is going to be deployed. I would've expected something similar from the deploy task but as long as I have a solution I'm happy.Make sure you have unchecked the
Remove files at destination
option.Already existing files get deleted if we check this option during the deployment.
If
usechecksum
option is enabled, the files get deployed only if there are any changes.If you want to deploy the
appsettings.json
file every time, then disable theusechecksum
option.Thanks @Alex AIT for the comment.
Yes, by using
Run from package
option we can avoid this type of issues.All the files are packaged in a zip folder and will be available after deployment.
We have an option to store
App Settings
in App Configuration.Refer Push settings and Pull settings with Azure Pipelines.