Azure ARM template Diagnostics - Tue, Dec 5, 2017
Is it even possible to enable Diagnostic Settings at resource creation using a Resource Manager template
ARM templates are terrible. The documentation is terrible. Everything is extremely inconsistent.
- You need a workspace
- You need to figure out the workspace id. No it’s not parameters(‘workspaceName’).Id because that would be too consistent. It is: /subscriptions//resourceGroups//providers/microsoft.operationalinsights/workspaces/
- Resources which need to have diagnostics and / or logging enabled need to have a resource added to them (resource within a resource).
- The resource name has to be “Microsoft.Insights/service”
- Some resources can have logs. You will need to enable them one by one for each resource. See a list of available logs for each resource here: https://docs.microsoft.com/en-us/azure/monitoring-and-diagnostics/monitoring-diagnostic-logs-schema
- Most resources have metrics. Find out which resources here: https://docs.microsoft.com/en-us/azure/monitoring-and-diagnostics/monitoring-supported-metrics#microsoftwebsites-excluding-functions
- Some resources do not validate with metrics enabled in the template. Why? Unknown.
Don’t try and create the resources manually and enable logging and/or metrics on them by hand to later get the template out of the Automation preferences, no, that template will not give you a single hint of how to enable logging or metrics.
I guess Powershell is the choice for infrastructure as code in Azure.