Management
Azure Monitor diagnostic setting
Routes supported platform logs or metrics from a resource to a monitoring destination.
Naming rules
- Abbreviation
- Length
- 1–260 (module guidance)
- Allowed characters
- See Microsoft’s resource reference.
- Uniqueness scope
- See resource reference
Azure Verified Modules naming utility v0.3.0 · AVM naming key monitor_diagnostic_setting
Code examples
These examples look up an existing resource by its full Azure resource ID. The documentation links include deployment syntax.
Terraform
Terraform documentationhcl
terraform {
required_providers {
azapi = {
source = "Azure/azapi"
version = "~> 2.0"
}
}
}
variable "resource_id" {
description = "Full Azure resource ID of the existing Microsoft.Insights/diagnosticSettings resource."
type = string
}
data "azapi_resource" "example" {
type = "Microsoft.Insights/diagnosticSettings@2016-09-01"
resource_id = var.resource_id
}
output "resource_name" {
value = data.azapi_resource.example.name
}
Bicep
Bicep documentationbicep
@description('Full resource ID of the existing Microsoft.Insights/diagnosticSettings resource.')
param resourceId string
output resourceName string = reference(resourceId, '2016-09-01', 'Full').name
ARM template
ARM template documentationjson
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"resourceId": {
"type": "string",
"metadata": {
"description": "Full resource ID of the existing Microsoft.Insights/diagnosticSettings resource."
}
}
},
"resources": [],
"outputs": {
"resourceName": {
"type": "string",
"value": "[reference(parameters('resourceId'), '2016-09-01', 'Full').name]"
}
}
}