3

For years we stored our environment variables in devops pipelines (for each environment) and had a custom powershell script for updating them on deploy.

enter image description here

recently on another project with similar need, I discovered that the task Àzure App Service Deploy had an app settings section, great. seems to be exactly what is needed to get rid of our powershell custom script.

however I didn't found (official documentation of the task doesn't mention it) how to re-use pipeline variables into task app settings. any idea if it's possible ?

enter image description here

camous
  • 998
  • 11
  • 27

1 Answers1

6

At the pipeline Variables you have to set your variables. Variables tab will look like: Variables tab

Once the variables are set you can use them at your release pipeline under Deploy Azure App Service task in format -key value. As per documentation:

Edit web app Application settings using the syntax -key value. Values containing spaces must be enclosed in double quotes. Examples: -Port 5000 -RequestTimeout 5000 and -WEBSITE_TIME_ZONE "Eastern Standard Time".

As you have values set the format will be -key $(VariableName). This format should be familiar as pipelines refer to release default variables.

So your App settings at Deploy Azure App Service task will look like

-Key1 $(Variable1) -Key2 $(Variable2)

or:

enter image description here

To reuse same variables over the pipelines you can setup Variable Group.

Anna
  • 2,988
  • 3
  • 15
  • 29