英文:
The resource type '/' does not support diagnostic settings
问题
我有以下的 Bicep 代码用于部署 Azure 数据工厂并配置诊断设置:
resource dataFactory 'Microsoft.DataFactory/factories@2018-06-01' = {
name: name
identity: {
type: 'SystemAssigned'
}
properties: {
globalParameters: {
environment: {
type: 'String'
value: environmentAbbreviation
}
}
}
location: location
}
resource diagnosticSettings 'Microsoft.Insights/diagnosticSettings@2021-05-01-preview' = {
name: name
properties: {
logs: [
{
category: 'PipelineRuns'
enabled: true
}
]
workspaceId: resourceId('microsoft.operationalinsights/workspaces','<Workspace-Name>')
logAnalyticsDestinationType: null
}
dependsOn: [
dataFactory
]
}
运行时,我看到它因以下错误而失败:
资源类型 '/ '不支持诊断设置。我漏掉了什么?
英文:
I have the following bicep to deploy Azure Data Factory with diagnostic setting:
resource dataFactory 'Microsoft.DataFactory/factories@2018-06-01' = {
name: name
identity: {
type: 'SystemAssigned'
}
properties: {
globalParameters: {
environment: {
type: 'String'
value: environmentAbbreviation
}
}
}
location: location
}
resource diagnosticSettings 'Microsoft.Insights/diagnosticSettings@2021-05-01-preview' = {
name: name
properties: {
logs: [
{
category: 'PipelineRuns'
enabled: true
}
]
workspaceId: resourceId('microsoft.operationalinsights/workspaces','<Workspace-Name>')
logAnalyticsDestinationType: null
}
dependsOn: [
dataFactory
]
}
On running this, I see it failing due to error:
> The resource type '/' does not support diagnostic settings. What am I missing?
答案1
得分: 1
"Microsoft.Insights/diagnosticSettings" 资源没有 dependsOn 属性。您需要使用 scope 属性。有关诊断资源的模板结构,请参考此文档。
以下是参考示例:
@description('数据工厂名称')
param dataFactoryName string = 'datafactory${uniqueString(resourceGroup().id)}';
@description('数据工厂的位置。')
param location string = resourceGroup().location;
@description('日志分析工作区的名称')
param workspaceid string;
@description('诊断设置的名称')
param diagname string;
resource dataFactory 'Microsoft.DataFactory/factories@2018-06-01' = {
name: dataFactoryName
location: location
identity: {
type: 'SystemAssigned'
}
}
resource diagnosticSettings 'Microsoft.Insights/diagnosticSettings@2021-05-01-preview' = {
name: diagname
scope: dataFactory
properties: {
logs: [
{
category: 'PipelineRuns'
enabled: true
}
]
workspaceId: workspaceid
logAnalyticsDestinationType: null
}
}
英文:
"Microsoft.Insights/diagnosticSettings" resource does not have dependsOn property. You need to use scope property. For template structure of diagnostic resource refer this document.
Here is sample example for reference.
@description('Data Factory Name')
param dataFactoryName string = 'datafactory${uniqueString(resourceGroup().id)}'
@description('Location of the data factory.')
param location string = resourceGroup().location
@description('Name of the log analytics workspace')
param workspaceid string
@description('Name of the diagnostic setting')
param diagname string
resource dataFactory 'Microsoft.DataFactory/factories@2018-06-01' = {
name: dataFactoryName
location: location
identity: {
type: 'SystemAssigned'
}
}
resource diagnosticSettings 'Microsoft.Insights/diagnosticSettings@2021-05-01-preview' = {
name: diagname
scope: dataFactory
properties: {
logs: [
{
category: 'PipelineRuns'
enabled: true
}
]
workspaceId: workspaceid
logAnalyticsDestinationType: null
}
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论