A better generic approach to diag policies

A better generic approach to diag policies

January 7, 2025 0 By Morten Lerudjordet

Maintaining azure diagnostic policies can be a bit of a slog, as existing approach often have a splattering of hardcoded values that need to be cared for.

With this in mind, I tried to look at the problem and come up with a better way of organizing the content of these policies.

  • Put all metric and log categories as parameters, and if any changes to these occur. One only need to edit and add/remove categories from a parameter in the given policy.
  • New diagnostic policy for azure service, is much easier using the framework below. Only need to edit and add service type (<serviceType>) and metric/log categories supported for service.
  • Not needing to delete assignment to update policy definition when changes to metric/log category occurs.

Below is an example of how to use for Azure Automation.

Happy tinkering!