Azure app settings task in Azure pipeline throws invalid JSON error when supplying with variable

SHEHUL PATEL 21 Reputation points
2022-02-01T22:37:47.937+00:00

Trying to update Azure Configuration using Azure Pipeline's Azure App Settings task as documented here: https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/deploy/azure-app-service-settings?view=azure-devops.

The link has a sample for appsettings as,

appSettings: |  
      [  
        {  
          "name": "APPINSIGHTS_INSTRUMENTATIONKEY",  
          "value": "$(Key)",  
          "slotSetting": false  
        },  
        {  
          "name": "MYSQL_DATABASE_NAME",  
          "value": "$(DB_Name)",   
          "slotSetting": false  
        }  
      ]  

However when we try to supply the same with a variable like this,

- task: AzureAppServiceSettings@1  
    displayName: Azure App Service Settings  
    inputs:  
        azureSubscription: $(subscriptionName)  
        appName: $(appServiceName)    
        resourceGroupName: $(resourceGroupName)         
        appSettings: $env:azureConfigurationSettings  

we receive error as

##[error]Error: Application Settings object is not a valid JSON.  

I have verified $env:azureConfigurationSettings is correct JSON via JSON validator as well as it successfully parses JSON.Parse(theActualValue).
When we put the actual value of variable as hardcoded string there is no error and the configuration gets updated.

Need help in determining,

  1. If this Azure appsettings task supports the supply of variable and if it does, what is the correct syntax. The variable is coming from Powershell script.

I looked at the source code at

https://github.com/microsoft/azure-pipelines-tasks/blob/master/Tasks/AzureAppServiceSettingsV1/azurewebappsettings.ts

and logically I think it should work.

Not Monitored
Not Monitored
Tag not monitored by Microsoft.
37,797 questions
{count} votes

Accepted answer
  1. MayankBargali-MSFT 70,016 Reputation points
    2022-02-02T05:18:21.66+00:00

    Hi @SHEHUL PATEL

    Welcome to Microsoft Q&A! Thanks for posting the question.

    DevOps is currently not supported in the Q&A forums, the supported products are listed over here https://learn.microsoft.com/en-us/answers/products (more to be added later on).

    You can ask the experts in the dedicated forum over here:
    https://stackoverflow.com/questions/tagged/devops
    https://developercommunity.visualstudio.com/spaces/21/index.html

    Please 'Accept as answer' and ‘Upvote’ if it helped so that it can help others in the community looking for help on similar topics.

0 additional answers

Sort by: Most helpful