A better diag policy for app service

A better diag policy for app service

December 26, 2024 0 By Morten Lerudjordet

I have long wanted to find the time to revisit refactoring the built-in version of diagnostic policy for app service. As this exhibits a couple of issues I want to tackle.

  • Remove as much of the tendency to use hardcoded values multiple places in the policy. Making maintenance more easy.
  • Add ways to filter out different types of app services based on something like tags.
  • add more dynamic ways to pull data from the service at runtime to make better choices.

What I came up with is the following:

  • Move definition of metric/log category names to monitor to parameters
  • Dont use log category names directly in the template, but reference parameter list insted. This makes maintenance easier to track.
  • Add filter option on tags to give the option to only include some app services. Like env = prod
  • Use runtime information from the app service itself, so the policy can determine dynamically what log categories are available on each instance processed.

This is what I came up with (JSON format):

What is nice is that this structure can be adopted for other services also.