c# - VSTS 部署 : Unable to replace variables in appsettings. json

标签 c# asp.net-core azure-pipelines azure-pipelines-release-pipeline

我有一个相当标准的 ASP.NET Core 应用程序设置 - GitHub 上的源代码控制和 Azure 上托管的实时应用程序,主分支更改触发 VSTS 上的 CI 构建。 数据库连接字符串位于 appsettings.json 中,通常指向 localdb 实例。为了部署到 Azure,我希望它指向一个 Azure SQL DB(我在第一次发布时忽略了设置)。 应用服务本身是在 Azure 上设置为没有数据库的应用服务——换句话说,我不应该在醒来后就这样做。但是,应用服务和数据库都链接到同一个资源组。

我面临的问题是,每当我通过 VSTS 触发 CI 构建时,构建工作正常,但版本在它尝试用 CI 构建变量中定义的连接字符串替换连接字符串时失败。

2017-07-09T08:47:02.7205410Z ##[section]Starting: Deploy Azure App Service 2017-07-09T08:47:02.7415413Z ============================================================================== 2017-07-09T08:47:02.7415413Z Task : Azure App Service Deploy 2017-07-09T08:47:02.7415413Z Description : Update Azure App Service using Web Deploy / Kudu REST APIs 2017-07-09T08:47:02.7415413Z Version : 3.3.9 2017-07-09T08:47:02.7415413Z Author : Microsoft Corporation 2017-07-09T08:47:02.7415413Z Help : 2017-07-09T08:47:02.7415413Z ============================================================================== 2017-07-09T08:47:06.5658468Z Got connection details for Azure App Service:'BlackscarsSheetsSwtor' 2017-07-09T08:47:07.6978989Z ##[error]Error: NO JSON file matched with specific pattern: appsettings,json.

我已经尝试了解决方案 here ,只会遇到完全相同的错误,尽管日志显示 **/appsettings.json 而不是 appsettings.json。

Deploy definition

这是 appsettings.json 文件

{
  "ConnectionStrings": {
    "DefaultConnection": "Server=(localdb)\\mssqllocaldb;Database=Telvee32.BlackscarsSheetsSwtor.Db;Trusted_Connection=True;MultipleActiveResultSets=true"
  },
  "Logging": {
    "IncludeScopes": false,
    "LogLevel": {
      "Default": "Warning"
    }
  }
}

这是我第一次使用构建和发布定义,所以我完全有可能搞砸了,但实际的定义是由 Azure 自动创建的,并且在我开始这样做之前工作正常,考虑到应用程序依赖于数据库,绝对需要正常工作。

最佳答案

我最初的想法是你拼错了 JSON 配置名称

Service:'BlackscarsSheetsSwtor' 2017-07-09T08:47:07.6978989Z ##[error]Error: NO JSON file matched with specific pattern: appsettings,json.

这里有一个逗号 , 而不是 .

您是否检查过这是否是问题的原因?

关于c# - VSTS 部署 : Unable to replace variables in appsettings. json,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44994983/

相关文章:

c# - 如何在返回 View 之前修改 Controller 中的查询字符串

c# - 没有为其他线程释放锁

javascript - 在 Razor 页面中使用 OnPost 页面处理程序处理 AJAX 请求

entity-framework - 当我运行我的项目时,EF Core 迁移是否自动运行?

azure - 如何在Azure数据工厂管道复制数据任务中使用变量

c# - 显式 IEnumerator<T> 实现 VS yield 返回实现

c# - C#.Net 中的可选返回

asp.net-web-api - 刷新 token - 多个客户端的服务器端存储和撤销

Azure Devops yaml管道,如何将foreach中的一系列步骤合并为一个步骤

azure-devops - 在 Azure DevOps 构建管道期间创建 json 文件