使用二头肌的Azure SQL故障转移组
我正在尝试使用二头肌模板实现Azure SQL故障转移组。我遇到的问题是,我无法弄清楚如何引用数据库的数据库数组作为故障转移组的数据库属性中传递的参数。在为数据库属性分配数组值时,它给了我期望字符串值的错误,而分配的是数组,这当然不正确。
resource symbolicname 'Microsoft.Sql/servers/failoverGroups@2021-11-01-preview' = {
name: 'string'
tags: {
tagName1: 'tagValue1'
tagName2: 'tagValue2'
}
parent: resourceSymbolicName
properties: {
databases: [
'string'
]
partnerServers: [
{
id: 'string'
}
]
readWriteEndpoint: {
failoverPolicy: 'string'
failoverWithDataLossGracePeriodMinutes: int
}
}
}
是否有人使用二头肌模板有任何有效的azure SQL故障转移组的示例,或者在解决方案上指向正确的方向?
编辑1- main.bicep: 这是我在添加Thomas的更改后尝试的代码:
param databases array
param primarySqlServerName string
param drSqlServerName string
param failovergroupName string
module primarySql '***************' = {
Deploy primary SQL Server and database
}
module drSql '****************' = {
Deploy secondary SQL Server
}
resource sqlServerFailoverGroup 'Microsoft.Sql/servers/failoverGroups@2020-11-01-preview' = {
name: '${primarySqlServerName}/${failovergroupName}'
properties: {
databases: [for database in databases: resourceId('Microsoft.Sql/servers/databases', primarySqlServerName, database)]
readWriteEndpoint: {
failoverPolicy: 'Automatic'
failoverWithDataLossGracePeriodMinutes: 60
}
readOnlyEndpoint: {
failoverPolicy: 'Enabled'
}
partnerServers: [
{
id: resourceId('Microsoft.Sql/servers', drSqlServerName)
}
]
}
dependsOn: [
primarySql
drSql
]
}
在上述部署时要低于错误:
无法处理在线资源的模板语言表达式 '1'和列“ 1289”。 '无法评估模板语言功能 'ResourceId':所有函数参数都必须是字符串文字。请 请参阅aka.ms/arm-template-expressions/#resourceid有关使用详细信息。
I am trying to implement Azure SQL failover group using Bicep templates. The problem I have is, I am unable to figure out how to reference array of databases passed as parameter in failover group's database property. When assigning array values to database property it gives me an error of expecting string values whereas assigned was array, which of course isn't correct.
resource symbolicname 'Microsoft.Sql/servers/failoverGroups@2021-11-01-preview' = {
name: 'string'
tags: {
tagName1: 'tagValue1'
tagName2: 'tagValue2'
}
parent: resourceSymbolicName
properties: {
databases: [
'string'
]
partnerServers: [
{
id: 'string'
}
]
readWriteEndpoint: {
failoverPolicy: 'string'
failoverWithDataLossGracePeriodMinutes: int
}
}
}
Does anyone have any working example of Azure SQL failover group using Bicep templates or point me in the right direction on the solution?
Edit 1 - main.bicep :
This is the code that I am trying after adding Thomas's changes:
param databases array
param primarySqlServerName string
param drSqlServerName string
param failovergroupName string
module primarySql '***************' = {
Deploy primary SQL Server and database
}
module drSql '****************' = {
Deploy secondary SQL Server
}
resource sqlServerFailoverGroup 'Microsoft.Sql/servers/failoverGroups@2020-11-01-preview' = {
name: '${primarySqlServerName}/${failovergroupName}'
properties: {
databases: [for database in databases: resourceId('Microsoft.Sql/servers/databases', primarySqlServerName, database)]
readWriteEndpoint: {
failoverPolicy: 'Automatic'
failoverWithDataLossGracePeriodMinutes: 60
}
readOnlyEndpoint: {
failoverPolicy: 'Enabled'
}
partnerServers: [
{
id: resourceId('Microsoft.Sql/servers', drSqlServerName)
}
]
}
dependsOn: [
primarySql
drSql
]
}
Getting below error while deploying above:
Unable to process template language expressions for resource at line
'1' and column '1289'. 'Unable to evaluate template language function
'resourceId': all function arguments must be string literals. Please
see aka.ms/arm-template-expressions/#resourceid for usage details.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
数据库
属性是字符串。Partnerservers
属性是对象的数组。两者都期望数据库的资源ID和合作伙伴服务器。
这是使用故障转移组SQL.BICEP的部署2个SQL服务器和数据库的简单示例
:
以及main.bicep文件:
The
databases
property is an of string. ThepartnerServers
property is an array of object.Both expect the resource id of the databases and partner servers.
Here is a simple sample of deploying 2 sql servers and databases with a failover group
sql.bicep:
and the main.bicep file: