Search code examples
azure-functionsazure-functions-core-tools

How can I configure ENV values from task AzureFunctionApp in ADO pipeline?


How can I configure ENV values from task AzureFunctionApp in ADO pipeline? Basically, when I have a FunctionApp that was created separately from Terraform, on this task that uploads the .jar file, how can I include some environment variables with the push?

Is this possible?

I tried this, but it doesn't work, and gets a compile error.

  - task: AzureFunctionApp@1
    inputs:
      azureSubscription: ${{ parameters.serviceConnection }}
      appType: 'functionApp'
      appName: 'my-api-$(environment)'
      package: '$(Pipeline.Workspace)/my-api/my-api-1.0.0'
      runtimeStack: 'JAVA|11'
      configurationStrings:
        - TEST: "what"

I also tried this, which compiles and runs, and it didn't work for me either. The env variable doesn't show up in the app settings after deploy.

  - task: AzureFunctionApp@1
    inputs:
      azureSubscription: ${{ parameters.serviceConnection }}
      appType: 'functionApp'
      appName: 'my-api-$(environment)'
      package: '$(Pipeline.Workspace)/my-api/my-api-1.0.0'
      runtimeStack: 'JAVA|11'
      appSettings: "-TEST what"

Solution

  • According to the Azure Function App Task Documentation, the yaml key that you need is appSettings

    Try this way:

      - task: AzureFunctionApp@1
        inputs:
          azureSubscription: ${{ parameters.serviceConnection }}
          appType: 'functionApp'
          appName: 'my-api-$(environment)'
          package: '$(Pipeline.Workspace)/my-api/my-api-1.0.0'
          runtimeStack: 'JAVA|11'
          appSettings: '-MY_ENV_VARIABLE test'
    

    Application settings should follow the syntax -key value. Values containing spaces should be enclosed in double quotes.