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

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

The resource type '/' does not support diagnostic settings

问题

我有以下的 Bicep 代码用于部署 Azure 数据工厂并配置诊断设置:

  1. resource dataFactory 'Microsoft.DataFactory/factories@2018-06-01' = {
  2. name: name
  3. identity: {
  4. type: 'SystemAssigned'
  5. }
  6. properties: {
  7. globalParameters: {
  8. environment: {
  9. type: 'String'
  10. value: environmentAbbreviation
  11. }
  12. }
  13. }
  14. location: location
  15. }
  16. resource diagnosticSettings 'Microsoft.Insights/diagnosticSettings@2021-05-01-preview' = {
  17. name: name
  18. properties: {
  19. logs: [
  20. {
  21. category: 'PipelineRuns'
  22. enabled: true
  23. }
  24. ]
  25. workspaceId: resourceId('microsoft.operationalinsights/workspaces','<Workspace-Name>')
  26. logAnalyticsDestinationType: null
  27. }
  28. dependsOn: [
  29. dataFactory
  30. ]
  31. }

运行时,我看到它因以下错误而失败:

资源类型 '/ '不支持诊断设置。我漏掉了什么?

英文:

I have the following bicep to deploy Azure Data Factory with diagnostic setting:

  1. resource dataFactory &#39;Microsoft.DataFactory/factories@2018-06-01&#39; = {
  2. name: name
  3. identity: {
  4. type: &#39;SystemAssigned&#39;
  5. }
  6. properties: {
  7. globalParameters: {
  8. environment: {
  9. type: &#39;String&#39;
  10. value: environmentAbbreviation
  11. }
  12. }
  13. }
  14. location: location
  15. }
  16. resource diagnosticSettings &#39;Microsoft.Insights/diagnosticSettings@2021-05-01-preview&#39; = {
  17. name: name
  18. properties: {
  19. logs: [
  20. {
  21. category: &#39;PipelineRuns&#39;
  22. enabled: true
  23. }
  24. ]
  25. workspaceId: resourceId(&#39;microsoft.operationalinsights/workspaces&#39;,&#39;&lt;Workspace-Name&gt;&#39;)
  26. logAnalyticsDestinationType: null
  27. }
  28. dependsOn: [
  29. dataFactory
  30. ]
  31. }

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 属性。有关诊断资源的模板结构,请参考此文档

以下是参考示例:

  1. @description('数据工厂名称')
  2. param dataFactoryName string = 'datafactory${uniqueString(resourceGroup().id)}';
  3. @description('数据工厂的位置。')
  4. param location string = resourceGroup().location;
  5. @description('日志分析工作区的名称')
  6. param workspaceid string;
  7. @description('诊断设置的名称')
  8. param diagname string;
  9. resource dataFactory 'Microsoft.DataFactory/factories@2018-06-01' = {
  10. name: dataFactoryName
  11. location: location
  12. identity: {
  13. type: 'SystemAssigned'
  14. }
  15. }
  16. resource diagnosticSettings 'Microsoft.Insights/diagnosticSettings@2021-05-01-preview' = {
  17. name: diagname
  18. scope: dataFactory
  19. properties: {
  20. logs: [
  21. {
  22. category: 'PipelineRuns'
  23. enabled: true
  24. }
  25. ]
  26. workspaceId: workspaceid
  27. logAnalyticsDestinationType: null
  28. }
  29. }
英文:

"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.

  1. @description(&#39;Data Factory Name&#39;)
  2. param dataFactoryName string = &#39;datafactory${uniqueString(resourceGroup().id)}&#39;
  3. @description(&#39;Location of the data factory.&#39;)
  4. param location string = resourceGroup().location
  5. @description(&#39;Name of the log analytics workspace&#39;)
  6. param workspaceid string
  7. @description(&#39;Name of the diagnostic setting&#39;)
  8. param diagname string
  9. resource dataFactory &#39;Microsoft.DataFactory/factories@2018-06-01&#39; = {
  10. name: dataFactoryName
  11. location: location
  12. identity: {
  13. type: &#39;SystemAssigned&#39;
  14. }
  15. }
  16. resource diagnosticSettings &#39;Microsoft.Insights/diagnosticSettings@2021-05-01-preview&#39; = {
  17. name: diagname
  18. scope: dataFactory
  19. properties: {
  20. logs: [
  21. {
  22. category: &#39;PipelineRuns&#39;
  23. enabled: true
  24. }
  25. ]
  26. workspaceId: workspaceid
  27. logAnalyticsDestinationType: null
  28. }
  29. }

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:

确定