使用Azure Devops更新.net核心中的appsettings.json值

问题描述

我在devop领域相对较新,自从我们devop的人离开后,我正在努力帮助我的团队。

我们正在通过Github / Azure管道部署该应用程序而没有任何问题, 但是在更新appsettings.json文件中的值时,我们无法做到这一点。

这是我们的appsettings.json文件的示例:

{
  "ConnectionStrings": {
    "DefaultConnection": "Server=tcp:ourserver.database.windows.net,1433;Initial Catalog=db;Persist Security Info=False;User ID=sampleuserid;Password=12321321321;"
  },"Stripe": {
    "SecretKey": "sk_live_addsd123213312O8756A","WebHookSecret": "whsec_Adsa8sd67i343ij3ij"
  }
}

我们要更新Stripe的SecretKey和WebHookSecret值。

我们有什么选择?

我已阅读到我们可以添加Azure应用设置服务任务并在其中包含值,我应该这样做吗?

enter image description here

P.S。我为Stripe提供的值仅用于演示目的。

解决方法

请使用Stripe__WebHookSecret而不是WebHookSecret,但这不会更新您的appsettings.json。如果在门户中定义了值,它将在Web App配置中设置设置,该设置将覆盖文件中的值。这是正确的方法。绝对比更新文件好。

您也可以尝试使用Stripe:WebHookSecret-请检查此site