I’ve written a lot in the past about using Azure Application Insights for monitoring a Dynamics 365 Business Central tenant (you can read here and here) and the team is actively working on improving the telemetry features by adding always more and more signals.
For a complete overview of handling the Dynamics 365 Business Central telemetry with Azure Application Insights, I suggest also to come at the Microsoft’s webcast planned for September 16th, where I’ll give you a complete overview of what you can do with this service.
Lots of partners are asking for the possibility to emit telemetry (custom signals) from their Dynamics 365 Business Central apps to Azure Applications Insights and this will be available in the upcoming version 17. Microsoft has publicly announced the details here, but after a lot of questions received I want to try to clear some things.
With Dynamics 365 Business Central version 17 you (as a partner or ISV) will be able to add your Application Insights Instrumentation Key to an extension for sending custom signals from AL code to your Application Insights instance. This could be done by adding the new applicationInsightsKey parameter in the extension’s app.json file:
P.S. in the above image, it’s a fictious GUID so don’t try to inject telemetry on my instance because it will not work 😀
This is the partner’s specific Azure Application Insights Key and telemetry from this extension will be published to the relevant Azure resource.
In your extension’s code (AL) you will be able to send custom signals to Application Insights by using the new Session.LogMessage function. This is an example of usage:
As you can see, it’s very simple. The new function has the following parameters:
Session.LogMessage( EventID : String , Message: String , DataClassification: DataClassification , Scope: ExtensionPublisher|All , Verbosity: Verbosity , Dimensions: Dictionary of [String, String] )
EventID is the ID of your event that you want to inject and Message is the message content for the event. If the Verbosity level is set to Normal and DataClassification is set to SystemMetadata, then the platform will emit telemetry to Application Insights. The value of the Scope parameter determines where telemetry will be sent. If set to ExtensionPublisher, telemetry is only sent to the Application Insights account specified in the app.json file. If set to All, telemetry is also sent to the Application Insights account specified in the Business Central administration center.
The event can have attached also a Dictionary of details that you need to transmit (Dimensions) that can be used for analysis on Application Insights.
Common questions I saw about this features:
- Is applicationInsightsKey mandatory? No. It’s totally up to you if handle app’s telemetry or not.
- In the applicationInsightsKey should I use my Partner’s Application Insights instance or customer’s one? This is for handling partner’s telemetry, so it must be your partner’s instance. This permits you to manage telemetry of all your apps in a centralized way.
- Should I pass the app details in the telemetry data that I send? No. Session.LogMessage sends details like extensionId, extensionName, extensionPublisher, extensionVersion as custom dimensions of your signals automatically.
- If I have customers on all over the world that uses my app, on which Azure Region my Azure Application Insights instance should be placed? This is up to you. You can have only one instance per app and this instance Instrumentation Key can’t be dinamically setted via code, so the suggestion is to create the Application Insights instance on your Azure region (for example West Europe if you’re located in Western Europe as a partner).
- Can I use these features just now? The new applicationInsightsKey and the LogMessage function is available from Dynamics 365 Business Central version 16.4 (runtime must be at least 5.4) but it will not work just now. It will emit telemetry to Application Insights starting from version 17.
My personal recommendation is always the same: use telemetry a lot!
NOTE: the SendTraceTag function (available only for the on-premise world) will be deprecated starting from version 17.