0

I am currently deploying an web application on which I have an appsetting for production purposes and one for test purposes. how do I during deploy replace the appsetting.json with the content of the production or test?

to deploy i use IIS web app manage and IIS web app deploy.

I am not Fat
  • 433
  • 9
  • 26
  • According to your description, I couldn’t understand your requirement clearly. What is your purpose in doing this? – samwu May 24 '22 at 07:35
  • The content of the transformed appsetting.json files is different when deploying I want to override use the environment specific and not the one set I appsetting.json – I am not Fat May 25 '22 at 10:02
  • Your problem seems complicated, I suggest you open a case via: https://support.microsoft.com. – samwu May 27 '22 at 09:30
  • I think you can use bash script in Linux or bat files in Windows , create a step in your pipeline to change appsetting.json – behrooz razzaghi May 30 '22 at 05:28

3 Answers3

0

deploying web app with env specific appsetting

Using the new version of the Azure App Service Deploy task makes it easy to implement this approach as long as you define the values of the settings that you want to replace in each environment

Refer Managing Configuration and App Settings for Multiple Environments in Your CD Pipeline

  • To replace application settings, add variables to the release task and send the json file for variable substitution into the task.

  • If you want to change app settings and connection strings value before deploying to each web app ,you can do this either by applying a Web.config transformation or by substituting variables in your Web.config file.

  • Based on the stage name supplied, the Azure App Service Deploy action allows users to edit configuration settings in configuration files (*.config files) inside web packages and XML parameters files (parameters.xml).

  • File transforms and variable substitution are also supported by the separate File Transform task for use in Azure Pipelines.

  • In "Deploy Azure App Service" release task you can see a File Transforms and Variable Substitution section.There you need to supply the path to the json file you want to swap variable values.

enter image description here

  • Click on the options button on the release environment. You will see an option to configure variables in the pop out menu.

enter image description here

  • Add the json property you want to modify as a variable.

  • Put in your connection string or App Settings value. Azure Devops will then swap out these values for you when deploying.

  • Configuration substitution is specified in the File Transform and Variable Substitution Options section of the settings for the tasks.

Please refer File transforms and variable substitution reference for more information

0

Have you tried using the Azure App Service Settings task?

FinneVirta
  • 35
  • 2
  • 8
0

If you do not want variable substitutions then maybe you can have 2 copies of the json one for prod and one for test and then use a copy task as described here: https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/utility/copy-files?view=azure-devops&tabs=yaml

You can add the copy in your deploy yaml and use the file you need based on the stage. After this copy task you can add your deploy task.