azure - 模板部署后输出 Azure SQL 数据库连接字符串

标签 azure connection-string azure-rm-template

我有一个 ARM 模板,它(以及其他模板)在 Azure SQL 服务器(也是由该模板创建的)上创建数据库。

我需要输出数据库ADO.NET连接字符串。

因为我不确定该键叫什么,所以我输出整个对象: 这是我在 JSON 模板文件中的内容:

 "DatabaseConnectionString": {
      "type": "object",
      "value": "[listkeys(variables('dbResourceId'), variables('apiVersion'))]"
    }

dbResourceId 100% 正确。如果我输出它,我会得到正确的 ID,并且 apiVersion 与我在创建数据库时使用的相同。 但是,我收到此错误:

"code": "NotFound",

"message": "Resource not found for the segment 'listkeys'.",

数据库正在正确创建

我对服务总线有完全相同的模式/想法,而且它工作得很好 救命,这害死我了

最佳答案

嗯,看起来连接字符串根本不是一个属性,这就是为什么它不能用listkeys返回,它需要使用concat“计算”

"DatabaseConnectionString": {
  "type": "string",
  "value": "[concat('Server=tcp:',reference(variables('sqlserverName')).fullyQualifiedDomainName,',1433;Initial Catalog=',variables('dbName'),';Persist Security Info=False;User ID=',reference(variables('sqlserverName')).administratorLogin,';Password=',reference(variables('sqlserverName')).administratorLoginPassword,';MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;')]"
}

关于azure - 模板部署后输出 Azure SQL 数据库连接字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40531799/

相关文章:

python - python azure函数中的错误404 HEAD依赖性

azure - Dot.Net Core 中的 Azure blob 容器中的软删除 blob 文件

azure - 自最新更新以来,将应用程序部署到 VS 2015 中的 azure 应用程序服务已损坏

mongodb - 使用 "Trusted Connection"连接到 Mongo 数据库的连接字符串的语法

node.js - 部署 Node 。 js 应用程序到 Azure

c# - Entity Framework - 如何将连接字符串更改为相对的?

sql-server - 如何在没有 DSN 的情况下连接到 ColdFusion 7 中的 SQL Server?

azure - Powershell 用于下载 Azure 数据工厂管道的 ARM 模板

Azure RM 模板 : Create multiple data disks of different sizes using copyIndex()

azure - 如何在 Azure 中进行测试 - Azure 资源管理器(ARM 模板)