资源类型 ‘/’ 不支持诊断设置

huangapple go评论97阅读模式
英文:

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 &#39;Microsoft.DataFactory/factories@2018-06-01&#39; = {
  name: name
  identity: {
    type: &#39;SystemAssigned&#39;
  }
  properties: {
    globalParameters: {
      environment: {
        type: &#39;String&#39;
        value: environmentAbbreviation
      }
    }
  }
  location: location
}

resource diagnosticSettings &#39;Microsoft.Insights/diagnosticSettings@2021-05-01-preview&#39; = {
  name: name
  properties: {
    logs: [
      {
        category: &#39;PipelineRuns&#39;
        enabled: true
    }
    ]
    workspaceId: resourceId(&#39;microsoft.operationalinsights/workspaces&#39;,&#39;&lt;Workspace-Name&gt;&#39;)
    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(&#39;Data Factory Name&#39;)
param dataFactoryName string = &#39;datafactory${uniqueString(resourceGroup().id)}&#39;

@description(&#39;Location of the data factory.&#39;)
param location string = resourceGroup().location

@description(&#39;Name of the log analytics workspace&#39;)
param workspaceid string

@description(&#39;Name of the diagnostic setting&#39;)
param diagname string

resource dataFactory &#39;Microsoft.DataFactory/factories@2018-06-01&#39; = {
  name: dataFactoryName
  location: location
  identity: {
    type: &#39;SystemAssigned&#39;
  }
}


resource diagnosticSettings &#39;Microsoft.Insights/diagnosticSettings@2021-05-01-preview&#39; = {
  name: diagname
  scope: dataFactory
  properties: {
    logs: [
      {
        category: &#39;PipelineRuns&#39;
        enabled: true
    }
    ]
    workspaceId: workspaceid
    logAnalyticsDestinationType: null
  }
}

huangapple
  • 本文由 发表于 2023年2月24日 08:02:29
  • 转载请务必保留本文链接:https://go.coder-hub.com/75551500.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定