如何使用Azure更新AppSettings.json值

发布于 2025-02-03 10:05:53 字数 614 浏览 4 评论 0 原文

我想获得一个构建号码并将其显示在我的网站徽标上。因此,只要有新的构建,我都需要一个新的构建号码并将其传递到appsettings.json文件,这样我就可以从那里获取构建号并使用它。

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

我想在AppSettings.json中通过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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

屋檐 2025-02-10 10:05:53

从本文档中:

App Service中配置的值覆盖了Web中的内容。 config或appsettings.json。

因此,只需更改为配置设置即可。

如何在Azure管道中进行操作:

1,创建服务连接:

“在此处输入图像说明”

“在此处输入映像说明”

2 :

“在此处输入图像描述”

”在此处输入图像描述”

“在此处输入图像说明”

“

“在此处输入图像描述”

:角色分配需要5分钟才能申请。

注意

( https://i.sstatic.net/ttvvi.png“ rel =“ nofollow noreferrer”>

“在此处输入图像描述”

”在此处输入图像描述”

https://i.sstatic.net/dfbgn.png“ alt =”在此处输入图像说明“>

noreferrer“> ”

如果使用yaml,那是

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

4,之后,等一下,它将成功:

“在此处输入图像描述”

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文