簡體   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