[英]Changing Azure PostgreSQL flexible server configuration with Bicep
Because of our app's requirements, we want to increase the PostgreSQL database property max_connections
to allow for more connections.由于我们应用程序的要求,我们希望增加 PostgreSQL 数据库属性
max_connections
以允许更多连接。 We are using Azure Bicep for deployment.我们正在使用 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'
}
}
This deployment sometimes works but often fails in the configuration step complaining about a conflict.此部署有时有效,但在配置步骤中经常失败并抱怨冲突。
Without the configuration step, deployment always succeeds.没有配置步骤,部署总是成功的。 Any idea what the problem could be?
知道问题可能是什么吗?
I was able to reproduce but the error message wasn't really helpful.我能够重现,但错误消息并没有真正的帮助。
Both AllowAccessFromAzure
and max_connections
resources have an implicit dependency on the server creation. AllowAccessFromAzure
和max_connections
资源都隐式依赖于服务器创建。 Once the server is created, these resources creation/update will be triggered in parallel and will try to update the server at the same time hence the error.创建服务器后,将并行触发这些资源创建/更新,并尝试同时更新服务器,因此出现错误。
By adding an explicit dependsOn
on the max_connections resource, it will force the creation/update to be done sequentially:通过在 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.