camous
camous

Reputation: 1000

Set Azure App Service environment variables with microsoft devops deploy task

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

Upvotes: 3

Views: 5128

Answers (1)

Anna
Anna

Reputation: 3256

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.

Upvotes: 6

Related Questions