azure-devopsazure-functionsazure-pipelinesazure-keyvault

Azure Function App Pipeline Error for Key Vault - Parameter name cannot be empty


Getting the following error:

##[error]Error: Failed to update App service 'function-app-name' application settings. Error: BadRequest - Parameter name cannot be empty. (CODE: 400)

I'm following the docs found here: https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/reference/azure-function-app-v2?view=azure-pipelines

Not sure why it's failing. Here is my task:

- task: AzureFunctionApp@2
            displayName: 'Azure functions app deploy'
            inputs:
              azureSubscription: '$(azureSubscription)'
              appType: functionAppLinux
              appName: $(functionAppName)
              package: '$(Pipeline.Workspace)/drop/$(Build.BuildId).zip'
              appSettings: |
                -AzureWebJobsStorage "@Microsoft.KeyVault(SecretUri=https://$(keyVaultName).vault.azure.net/secrets/AzureWebJobsStorage)"
                -repeatorderstorage_STORAGE "@Microsoft.KeyVault(SecretUri=https://$(keyVaultName).vault.azure.net/secrets/repeatorderstorage-STORAGE)"
                -AZURE_OPENAI_API_KEY "@Microsoft.KeyVault(SecretUri=https://$(keyVaultName).vault.azure.net/secrets/AZURE-OPENAI-API-KEY)"
                -AZURE_OPENAI_ENDPOINT "@Microsoft.KeyVault(SecretUri=https://$(keyVaultName).vault.azure.net/secrets/AZURE-OPENAI-ENDPOINT)"
                -AZURE_OPENAI_API_VERSION "@Microsoft.KeyVault(SecretUri=https://$(keyVaultName).vault.azure.net/secrets/AZURE-OPENAI-API-VERSION)"

Solution

  • To use multiline App settings key and value add a blank space at end of the each line. for example:

    appSettings: |
    -key1 value1 
    -key2 value2 
    -key3 value3 
    

    As you can see in the below screenshot there is a blank space after the key and value.

    Below file worked for me

    steps:
              - task: AzureFunctionApp@1
                displayName: 'Azure functions app deploy'
                inputs:
                  azureSubscription: '$(azureSubscription)'
                  appType: functionAppLinux
                  appName: $(functionAppName)
                  package: '$(Pipeline.Workspace)/drop/$(Build.BuildId).zip'
                  appSettings: |
                    -AzureWebJobsStorage "@Microsoft.KeyVault(SecretUri=https://$(keyVaultName).vault.azure.net/secrets/)" 
                    -repeatorderstorage_STORAGE "@Microsoft.KeyVault(SecretUri=https://$(keyVaultName).vault.azure.net/secrets/)" 
                    -AZURE_OPENAI_API_KEY "@Microsoft.KeyVault(SecretUri=https://$(keyVaultName).vault.azure.net/secrets/)" 
                    -AZURE_OPENAI_ENDPOINT "@Microsoft.KeyVault(SecretUri=https://$(keyVaultName).vault.azure.net/secrets/)" 
                    -AZURE_OPENAI_API_VERSION "@Microsoft.KeyVault(SecretUri=https://$(keyVaultName).vault.azure.net/secrets/)" 
                    -Test Vivek 
    

    OUTPUT: