我们有一个 DeployIfNotExists 策略,可以对环境中的资源创建诊断设置。该策略包含诊断设置的 ARM 模板,该模板在评估资源上不存在该设置时触发。请参见下文:(这是 Azure Bastion 主机的一个示例设置)
"resources": [
{
"type": "Microsoft.Network/bastionHosts/providers/diagnosticSettings",
"apiVersion": "2017-05-01-preview",
"name": "[concat(parameters('resourceName'), '/Microsoft.Insights/', parameters('profileName'))]",
"location": "[parameters('location')]",
"dependsOn": [],
"properties": {
"eventHubAuthorizationRuleId": "[parameters('eventHubRuleId')]",
"eventHubName": "[parameters('eventHubName')]",
"logs": [
{
"category": "BastionAuditLogs",
"enabled": true
}
]
}
}
],
Event Hub Authorization Rule ID 有一行,我们传入一个参数。早些时候,我们只是传递了我们的主要事件中心的信息。但是,某些位于不同区域的资源会失败,因为它们无法跨区域写入事件中心。因此,现在我们正在使用 Geo-Recovery Alias。
我们有一个地理恢复 DR 别名,用于连接两个不同区域的主要/次要事件中心。我想为此 DR Alias 传递 EventHubAuthorizationRuleID,但是这样做会出现以下问题:
Resource type 'microsoft.eventhub/namespaces/disasterrecoveryconfigs/authorizationrules' is invalid for property 'properties.eventHubAuthorizationRuleId'. Expected types are 'microsoft.servicebus/namespaces/authorizationrules', 'microsoft.eventhub/namespaces/authorizationrules
我们使用以下 Powershell 命令获取 DR 别名的授权规则:
PS: Get-AzEventHubAuthorizationRule -AliasName xxxxxxxxxxxxxx -Namespace xxxxxxxxxxxx -ResourceGroupName xxxxxxxxxxxxxxxx
Id : /subscriptions/xxxxxxxxxxxxxxxxxxxx/resourceGroups/xxxxxxxxxxxx/providers/Microsoft.EventHub/namespaces/xxxxxxxxxxx/disasterRecoveryConfigs/xxxxxxxxxxxxxxx/AuthorizationRules/RootManageSharedAccessKey
Type : Microsoft.EventHub/Namespaces/AuthorizationRules
Name : RootManageSharedAccessKey
Location :
Tags :
Rights : {Listen, Manage, Send}
上面的 ID 是我们作为参数传入的,是导致失败的原因。Powershell 响应中的类型是“Microsoft.EventHub/Namespaces/AuthorizationRules”,即使它明确包含“disasterRecoveryConfigs”部分。
问题:我们如何引用 DR Alias 以便将其作为常规命名空间读取?