繁体   English   中英

使用 Bicep 更改 Azure PostgreSQL 灵活的服务器配置

[英]Changing Azure PostgreSQL flexible server configuration with Bicep

由于我们应用程序的要求,我们希望增加 PostgreSQL 数据库属性max_connections以允许更多连接。 我们正在使用 Azure Bicep 进行部署。

resource dbServer 'Microsoft.DBforPostgreSQL/flexibleServers@2021-06-01' = {
  name: serverName
  location: location
  sku: {
    name: 'Standard_B1ms'
    tier: 'Burstable'
  }
  properties: {
    createMode: 'Default'
    version: '13'
    administratorLogin: administratorLogin
    administratorLoginPassword: administratorLoginPassword
    storage: {
      storageSizeGB: 32
    }
    backup: {
      backupRetentionDays: 7
      geoRedundantBackup: 'Disabled'
    }
  }

  resource allowAzureAccess 'firewallRules' = {
    name: 'AllowAccessFromAzure'
    properties: {
      startIpAddress: '0.0.0.0'
      endIpAddress: '0.0.0.0'
    }
  }
}

resource dbServerMaxConnections 'Microsoft.DBforPostgreSQL/flexibleServers/configurations@2021-06-01' = {
  parent: dbServer
  name: 'max_connections'
  properties: {
    value: '100'
    source: 'user-override'
  }
}

此部署有时有效,但在配置步骤中经常失败并抱怨冲突。

失败

没有配置步骤,部署总是成功的。 知道问题可能是什么吗?

我能够重现,但错误消息并没有真正的帮助。

AllowAccessFromAzuremax_connections资源都隐式依赖于服务器创建。 创建服务器后,将并行触发这些资源创建/更新,并尝试同时更新服务器,因此出现错误。

通过在 max_connections 资源上添加显式的dependsOn ,它将强制创建/更新按顺序完成:

resource dbServer 'Microsoft.DBforPostgreSQL/flexibleServers@2021-06-01' = {
  name: serverName
  ...

  resource allowAzureAccess 'firewallRules' = {
    name: 'AllowAccessFromAzure'
    properties: {
      startIpAddress: '0.0.0.0'
      endIpAddress: '0.0.0.0'
    }
  }

  resource dbServerMaxConnections 'configurations' = {
    name: 'max_connections'
    properties: {
      value: '100'
      source: 'user-override'
    }
    dependsOn:[
      allowAzureAccess
    ]
  }
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM