[英]How to setup EventHub disasterRecoveryConfigs using Azure bicep?
我创建了一个模块“resources.bicep”以在两个区域中创建事件中心命名空间。
resource eventHubNamespace 'Microsoft.EventHub/namespaces@2021-11-01' = {
name: resourceName
location: location
sku: {
name:'Standard'
tier:'Standard'
capacity:1
}
}
resource eventHub 'Microsoft.EventHub/namespaces/eventhubs@2021-11-01' = if (shortRegion == 'wus2') {
name: 'city-temprature'
parent: eventHubNamespace
properties: {
messageRetentionInDays: 1
partitionCount: 2
}
}
从父二头肌文件中,我将模块运行为
module weatherWest 'resources.bicep' = {
name:'westResources'
scope:resourceGroup('${name}-wus2')
params: {
name: name
shortRegion: 'wus2'
location: 'westus2'
}
}
module weatherEast 'resources.bicep' = {
name:'eastResources'
scope:resourceGroup('${name}-eus2')
params: {
name: name
shortRegion: 'eus2'
location: 'eastus2'
}
}
如何设置 GeoPairing? 我还没有找到从父二头肌文件调用Microsoft.EventHub/namespaces/disasterRecoveryConfigs@2021-11-01
的方法。
根据文档,
您需要指定parent
资源。 您可以使用existing
关键字查找现有资源。
沿着这些方向的东西应该起作用。
resource primary 'Microsoft.EventHub/namespaces@2021-11-01' existing = {
name: 'primaryEventHubName'
resource secondary 'Microsoft.EventHub/namespaces@2021-11-01' existing = {
name: 'secondaryEventHubName'
resource symbolicname 'Microsoft.EventHub/namespaces/disasterRecoveryConfigs@2021-11-01' = {
name: 'foo'
parent: primary
properties: {
alternateName: 'string'
partnerNamespace: secondary.id
}
}
我得到了 Azure Bicep 团队的帮助,目前无法将资源作为 output 传递,但他们正在制定提案。 现在有一个技巧可以工作,直到优雅的解决方案出现,使用existing
并在 Geo Pairing 片段上设置dependsOn
。 结束代码如下所示。
module allResources 'resources.bicep' = [for location in locations : {
name:'allResources'
scope:resourceGroup('${name}-${location.shortRegion}')
params: {
name: name
shortRegion: location.shortRegion
location: location.region
}
}]
resource primaryEventHubNamespace 'Microsoft.EventHub/namespaces@2021-11-01' existing = {
name: '${name}wus2'
}
resource disasterRecoveryConfigs 'Microsoft.EventHub/namespaces/disasterRecoveryConfigs@2021-11-01' = {
name: name
parent: primaryEventHubNamespace
properties: {
partnerNamespace: resourceId('${name}-eus2', 'Microsoft.EventHub/namespaces', '${name}eus2')
}
dependsOn: [
allResources
]
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.