I am adding some appsettings for a function app in YAML:
steps:
- download: current
displayName: Download app artifact
artifact: app
- task: AzureAppServiceSettings@1
displayName: Azure App Service Settings
inputs:
azureSubscription: ssubscription
appName: appname
appSettings: |
[
{
"name": "VarOne",
"value": "$(VAR_ONE)",
"slotSetting": false
},
{
"name": "VarTwo",
"value": "$(VAR_TWO)",
"slotSetting": false
},
{
"name": "VarThree",
"value": "$(VAR_THREE)",
"slotSetting": false
}
]
Is it possible to provide a template json file for appsettings? Something like:
appSettings: templates\appSettings.json
Is it possible to provide a template json file for appsettings?
According to the Azure App Service Settings v1 task Inputs, the input appSettings
is a string, so we cannot use a template json file for appsettings
field.
However, you can consider referring the step templates with parameters to use a template appSettings.yml
. This way, you only need to change the template appSettings.yml
when you want to update the appSettings
.
templates/appSettings.yml:
parameters:
- name: appSettings
type: object
default:
[
{
"name": "key1",
"value": "value111",
"slotSetting": false
},
{
"name": "key2",
"value": "value222",
"slotSetting": true
}
]
steps:
- task: AzureAppServiceSettings@1
displayName: Azure App Service Settings
inputs:
azureSubscription: 'subscription'
appName: 'appname'
resourceGroupName: 'GroupName'
appSettings: '${{ convertToJson(parameters.appSettings) }}'
main YAML file:
trigger:
- none
pool:
vmImage: windows-latest
steps:
- other steps
- template: templates/appSettings.yml # Template reference
- other steps
If your appSettings.json
file is from the Download app artifact task
, the above may not work. In this case, you can use the way mentioned in Rui's answer that using an AzureCLI task with the az webapp config appsettings set
command.
Sample YAML:
trigger:
- none
pool:
vmImage: windows-latest
steps:
- download: current
displayName: Download app artifact
artifact: app
- task: AzureCLI@2
inputs:
azureSubscription: 'subscription'
scriptType: 'batch'
scriptLocation: 'inlineScript'
inlineScript: |
az webapp config appsettings set --resource-group groupname --name appname --settings "@templates/appSettings.json"