Rnue
Rnue

Reputation: 105

How to update appsettings.json value using Azure

I want to get a build number and display it on my website logo. So whenever there is a new build, I want a new build number and pass it to the AppSettings.json file so then I can fetch the build number from there and use it.

"AppSettings": {
    "EmailPopPort": "111",
    "PopEmail": "[email protected]",
    "PopPassword": "sBzce",
    "AvailableStacks": [
      "AAA",
      "Plan",
      "US"
    ],
    "SmsProvider": "SmsGlobal",
    "Version":  "Dev"
    }

I want to update the above "Version" In appsettings.json through the pipeline in Azure. What would be the best technique to do that?

Upvotes: 3

Views: 3452

Answers (1)

Bowman Zhu
Bowman Zhu

Reputation: 7146

From this document:

https://learn.microsoft.com/en-us/azure/app-service/configure-common?tabs=portal#configure-app-settings

the values of configuration in App Service override the ones in Web.config or appsettings.json.

So, just need to change to configuration settings is ok.

How to do it in Azure pipeline:

1, Create a service connection:

enter image description here

enter image description here

2, Give the related service principal required permission:

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

(Note: The role assign need 5 minutes to apply, please wait.)

3, Use DevOps pipeline to change the app settings:

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

If you use YAML, it is

steps:
- task: AzureAppServiceSettings@1
  displayName: 'xxx'
  inputs:
    azureSubscription: xxx
    appName: xxx
    resourceGroupName: 'xxx'
    appSettings: |
     [
        {
         "name": "bowmantest",
         "value": "bowmantestvalue",
         "slotSetting": false
        }
     ]

4, After that, just wait, it will be successful:

enter image description here

Upvotes: 4

Related Questions