azureazure-devopsazure-functionsazure-pipelinescicd

Azure dev ops cicd yaml variable for appSettings, multi line causing an error


I have an Azure Dev Ops Yaml file for creating an Azure Function, one of the variables is for appSettings which requires a string, so if i put

appSettings: -val1 ${{ variable.foo }} -val2 ${{ variable.bar}}

it works however when i do this

appSettings: |
    -val1 ${{ variable.foo }}
    -val2 ${{ variable.bar}}
    ...add more variables here

I often get errors saying the is a variable which is empty, however when i go back to the all on one line it works, but managing the single line input isn't a great experience.

is there a different way to achieve a multi line approach?


Solution

  • I can reproduce the same issue when pass the application settings (-key value) as multi-line strings to the appSettings field on the task like as yours.

    However, if I add an extra whitespace after each line like as below, the task can work fine and the appSettings can be applied to the function app as expected.

      - task: AzureFunctionApp@2
        displayName: 'Deploy Function App'
        inputs:
          connectedServiceNameARM: 'myArmConnection'
          appType: 'functionAppLinux'
          appName: 'myFunctionApp'
          deployToSlotOrASE: true
          resourceGroupName: 'myResourceGroup'
          slotName: 'production'
          package: '$(Build.ArtifactStagingDirectory)/**/*.zip'
          appSettings: |
            -set1 val11 
            -set2 val22 
            -set3 val33 
          deploymentMethod: 'zipDeploy'
    

    enter image description here