Azure SQL 故障转移组在第二次运行时失败

问题描述 投票:0回答:1

我使用二头肌设置了一个 AzureSQL 故障转移组,设置非常简单。第一次部署按预期工作。如果我再次部署,而不进行任何更改,我会收到此错误:

只读端点的属性 targetServer 必须是为故障转移组配置的 PartnerServer 中存在的有效服务器。

第二次运行使用与之前相同的服务器,并且所有服务器都应该有效。

我不确定这告诉我什么?

这是我的二头肌:

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'
    }
    partnerServers: [
      {
        id: secondary.id
      }
    ]
  }
}
azure azure-sql-database azure-bicep
1个回答
0
投票

Azure SQL 故障转移组在第二次运行时失败:

我再次尝试部署与此SO中给出的相同的代码,并且能够按预期部署它,如下所示。

enter image description here

尝试清除缓存并再次部署整个二头肌代码。或者使用

az bicep restore --file filename.bicep
恢复具有相应路径的二头肌文件,以便恢复当前环境中的文件。

如果问题仍然存在,请在

target server
下添加
readOnlyEndpoint
(辅助服务器)属性,如下所示,以避免出现错误。

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: secondary.id
    }
     partnerServers: [
      {
        id: secondary.id
      }
     ]
   }
 }

部署成功:

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.