When looking at the traces of your Azure Functions in Application Insights, you might want some additional information available. You can add code to the function to allow custom tags to be added which you can then query on in Application Insights.
Adding the Tag in Your Function
To add the tag in your Azure function, you need to add a reference to System.Diagnostics
and then call Activity.Current.AddTag
to add your tag in the application insights log.
For example, a function that has a property "Account Number" could add this to the log thus:
#region Tracing telemetry
Activity.Current.AddTag("Account Number", accountnumber);
#endregion
Querying the Tag
In your application insights query, you can use the customDimension
function to access your custom tag.
History
- 7th February, 2021: First version