Skip to content

Instantly share code, notes, and snippets.

@matsest
Last active August 17, 2022 06:35
Show Gist options
  • Save matsest/ebd92760408b07040104c7847f32195a to your computer and use it in GitHub Desktop.
Save matsest/ebd92760408b07040104c7847f32195a to your computer and use it in GitHub Desktop.
Management Group Diagnostic Settings
targetScope = 'managementGroup'
param name string
param displayName string = name
param parentName string = ''
param workspaceResourceId string = ''
resource managementGroup 'Microsoft.Management/managementGroups@2021-04-01' = {
name: name
scope: tenant()
properties: {
displayName: displayName
details: empty(parentName) ? {} : {
parent: {
id: '/providers/Microsoft.Management/managementGroups/${parentName}'
}
}
}
}
module diag 'mg-diagsettings.bicep' = if(!empty(workspaceResourceId)) {
scope: managementGroup
name: '${name}-diag'
params: {
profileName: 'log-analytics'
workspaceResourceId: workspaceResourceId
}
}
output id string = managementGroup.id
targetScope = 'managementGroup'
param workspaceResourceId string
param profileName string
resource diag 'Microsoft.Insights/diagnosticSettings@2021-05-01-preview' = {
name: profileName
properties: {
workspaceId: workspaceResourceId
logs: [
{
category: 'Administrative'
enabled: true
}
{
category: 'Policy'
enabled: true
}
]
}
}
output id string = diag.id
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment