user989988
user989988

Reputation: 3746

The resource type '/' does not support diagnostic settings

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?

Upvotes: 1

Views: 1846

Answers (1)

SwathiDhanwada
SwathiDhanwada

Reputation: 538

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

Upvotes: 1

Related Questions