We are using AzureRmWebAppDeployment@4 for deploying our web app into an Azure App Service via a yaml file. So far, so good.
Now we want to set few settings from yaml, rather than using a .json or .xml file
Currently we do it manually through the Azure Portal -> App Services -> Configuration -> Application Settings (see screenshot below)
How we can do it programmatically from a yaml pipeline?

It won't be easy to keep variables directly in YAML file especially in the same file as pipeline and set configuration of App Service. For sure you should use Azure App Service Settings task:
- task: AzureAppServiceSettings@0
displayName: Azure App Service Settings
inputs:
azureSubscription: $(azureSubscription)
appName: $(WebApp_Name)
# To deploy the settings on a slot, provide slot name as below. By default, the settings would be applied to the actual Web App (Production slot)
# slotName: staging
appSettings: |
[
{
"name": "APPINSIGHTS_INSTRUMENTATIONKEY",
"value": "$(Key)",
"slotSetting": false
},
{
"name": "MYSQL_DATABASE_NAME",
"value": "$(DB_Name)",
"slotSetting": false
}
]
generalSettings: |
[
{
"name": "WEBAPP_NAME",
"value": "$(WebApp_Name)",
"slotSetting": false
},
{
"name": "WEBAPP_PLAN_NAME",
"value": "$(WebApp_PlanName)",
"slotSetting": false
}
]
connectionStrings: |
[
{
"name": "MysqlCredentials",
"value": "$(MySQl_ConnectionString)",
"type": "MySql",
"slotSetting": false
}
]
And you can use variables from pipeline (or variable group) to feed this task or read them from another file and set variables programitacally in powershell task using this syntax:
- bash: |
echo "##vso[task.setvariable variable=sauce]crushed tomatoes"
But please consider keeping your settings in Azure Key Vault. In this way you can feed your variable group and keep configuration in safe place. Please check this link.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With