You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Azure SQL故障转移组二次无修改部署失败求助

Azure SQL故障转移组二次部署报错解决方案

错误原因

首次部署故障转移组后,Azure会自动为readOnlyEndpoint填充targetServer属性(指向辅助服务器)。二次部署时,你的Bicep代码未显式指定该属性,ARM在增量部署的属性对比中会尝试重置此值,触发系统校验——只读端点的目标服务器必须属于故障转移组配置的partnerServers列表,从而抛出错误。

解决方法

在readOnlyEndpoint块中显式添加targetServer属性,指定辅助服务器的ID,确保二次部署时属性值与现有资源一致。

修改后的Bicep代码:

param failoverGroupName string
param primarySqlServerName string
param secondarySqlServerName string
param databaseName string
param secondaryResourceGroup string

resource primary 'Microsoft.Sql/servers@2022-08-01-preview' existing = {
  name:  primarySqlServerName
}

resource secondary 'Microsoft.Sql/servers@2022-08-01-preview' existing = {
  name:  secondarySqlServerName
  scope: resourceGroup(secondaryResourceGroup)
}

resource sqlServerFailoverGroup 'Microsoft.Sql/servers/failoverGroups@2023-05-01-preview' = {
  name: failoverGroupName
  parent: primary
  properties: {
    databases: [
      resourceId('Microsoft.Sql/servers/databases', primarySqlServerName, databaseName)
    ]
    readWriteEndpoint: {
      failoverPolicy: 'Automatic'
      failoverWithDataLossGracePeriodMinutes: 60
    }
    readOnlyEndpoint: {
      failoverPolicy: 'Enabled'
      targetServer: {
        id: secondary.id
      }
    }
    partnerServers: [
      {
        id: secondary.id
      }
    ]
  }
}

补充说明

显式声明targetServer后,ARM部署引擎会确认该值与已存在的故障转移组配置匹配,不会触发校验逻辑。此外,当前使用的API版本(2022-08-01-preview和2023-05-01-preview)均兼容故障转移组的配置要求,无需调整版本。

内容的提问来源于stack exchange,提问作者Don Chambers

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.25 16:37:42