If you want to add the appsettings to the function app as part of the function app deployment task. You can use variables to make it a little easier to maintain. You can check below steps.
Define the key/values of appsettings in the pipeline variables.
You can aslo define the variables in the YAML file:
variables:
key1: value1
key2: value2
Then then refer to variables in appsettings field of app service deployment task
- task: AzureRmWebAppDeployment@4
inputs:
AppSettings: '-key1 $(key1) -key2 $(key2)'
Another workaround is to use Azure App Service Settings task to add the appsettings to the function app. (You don't need to define appSettings field for app deployment task if App Service Settings task is used to add appsettings)
- task: AzureAppServiceSettings@0
displayName: Azure App Service Settings
inputs:
azureSubscription: $(azureSubscription)
appName: $(FunctionApp_Name)
appSettings: |
[
{
"name": "key1",
"value": "$(Key1)",
"slotSetting": false
},
{
"name": "key2",
"value": "$(Key2)",
"slotSetting": false
},
{
"name": "MYSQL_DATABASE_NAME",
"value": "$(DB_Name)",
"slotSetting": false
}
So by using above workarounds, you only need to change the values in the pipeline's variables to change the appsettings for function app.
You can also use terraform to add appsettings to you function app. Please check out the detailed steps in this tutorial Automating infrastructure deployments in the Cloud with Terraform and Azure Pipelines.