如何使用Bicep为所有api配置APIM的诊断设置



我已经使用Bicep创建了一个APIM服务、LogAnalyticWorkSpace和AppInsight资源。现在我想添加诊断设置到所有API使用二头肌。我可以在api级别上做到这一点,但我如何在";所有API";使用二头肌。

我用来配置API级别的代码

resource apiManagementServiceName_api_name 'Microsoft.ApiManagement/service/apis@2021-08-01' = {
parent: apiManagementServiceName_resource
name: api_name
properties: {
displayName: api_name
apiRevision: '1'
subscriptionRequired: true
path: api_name
protocols: [
'https'
] 
}
}
resource apiManagementAPIAppInsights 'Microsoft.ApiManagement/service/apis/diagnostics@2021-08-01'={
name:'appInsights'
parent:apiManagementServiceName_api_name
properties:{
loggerId:loggerid
alwaysLog:'allErrors'
verbosity:'error'
}
}

我想配置一个设置,在UI上显示在这里

Azure APIM设置

我们需要为此使用服务/记录器和服务/诊断

resource apiManagementLogging 'Microsoft.ApiManagement/service/loggers@2021-08-01'={
name:'${apiManagementServiceName}/${appInsightName}'
properties:{
loggerType:'applicationInsights'
description:'Logger resources for APIM'
credentials:{
instrumentationKey:instrumentationKey   
}
}
}
resource apiManagemementDiagnostics 'Microsoft.ApiManagement/service/diagnostics@2021-08-01'={
name:'applicationinsights'
parent:apiManagementServiceName_resource
properties:{
loggerId:apiManagementLogging.id
alwaysLog:'allErrors'
}
dependsOn:[apiManagementLogging]
}

最新更新