skip to Main Content

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


  1. Chosen as BEST ANSWER

    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 the zip 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.


  2. Make sure you have unchecked the Remove files at destination option.

    enter image description here

    Already existing files get deleted if we check this option during the deployment.

    There is a -useCheckSum argument provided to the task if that makes any difference.

    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 the usechecksum option.

    Thanks @Alex AIT for the comment.

    "run from package" deployment which cannot suffer from these issues. Is this an option for you?

    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.

    enter image description here

    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.

    We have an option to store App Settings in App Configuration.
    Refer Push settings and Pull settings with Azure Pipelines.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search