azureazure-devopsazure-web-app-serviceappsettings

Azure App Service Deploy - Not able to override appsettings.json


I have an Azure App Service Deploy task in my pipeline to deploy my Web Api Core app to the Azure App Service. The task has the following yaml -

- task: AzureRmWebAppDeployment@4
  inputs:
    ConnectionType: 'AzureRM'
    azureSubscription: 'myserviceconnection'
    appType: 'webAppLinux'
    WebAppName: 'mytestwebapp'
    packageForLinux: '$(Build.ArtifactStagingDirectory)/**/*.zip'
    AppSettings: 'TestWebApp/TestWebApp/appsettings.json'

I have been following this document on how to update the settings in .json files. From what I could understand, I had to create a variable in the pipeline which matches the key I need to update. Let's say I have the following Json structure in my appsettings.json -

{
  "AllowedHosts": "*",
  "ServiceConfiguration": {
    "Key1": "value1",
    "Key2": {
      "Key3": "value3",
      "Key4": "value4"
    }
  }
}

Suppose I have to update key1 to somenewvalue1 and key2.key3 to someothervalue3 and so on. So I created new variables by hitting the Variables button on the pipeline and added Key1 and key2.key3 as variables with appropriate values (as a side note, the value is a constant string, but I want this to be a dynamic value which will be provided by another task in the pipeline). Also, I provided the path for the appsetting file as shown in the image below -

enter image description here

But, when I run the pipeline, I get the following error-

enter image description here

Error: BadRequest - Parameter name cannot be empty. (CODE: 400)

I came across this SO question and also created the app setting on azure portal, but this also didn't work

What am I doing wrong here.

As a side question, As seen in the first image, what is the difference between File Transformation & Variable Substitution Options and Application and Configuration Settings and when to use what.

EDIT

Based on the comment, I was able to resolve the issue, so no more errors and I was able to verify the updated setting in the azure portal.

However, when I see the appsetting.json from Kudu inside the Site wwwroot folder under Browse Directory, I couldn't see it updated. Why are these valuees different, and if so, which value is actually considered.

Thanks


Solution

  • So it seems that one expects JSON containing the settings, and not a file path.

    As for the settings file not updating, that is expected. This is updating the settings in the Configuration tab of the App Service, which will be passed to your app as environment variables. It won't update the file. Instead it sets settings that override settings in the file (at least by default if you the default host builder). It'll only override settings you specify.