Telemetry and Monitoring Extensions

Earn 25 points (50 with Pro) in two steps

  1. ① Read through the lesson — each section gets a ✓ as you scroll through it.
  2. ② When every section has a ✓, tap Complete lesson.

0 of 12 read · keep scrolling

✦ See fewer ads and earn double points — 50 a lesson instead of 25 — with Pro

Lesson: Telemetry and Monitoring Extensions in Microsoft Dynamics 365 Business Central

Introduction: The Critical Role of Observability

In the world of cloud-based enterprise resource planning (ERP) systems like Microsoft Dynamics 365 Business Central, the days of "set it and forget it" deployments are long gone. When your business logic runs in a multi-tenant, software-as-a-service (SaaS) environment, you lose direct access to the underlying server logs, Windows Event Viewer, or SQL Server Profiler. This shift necessitates a new approach to understanding how your customizations, integrations, and extensions are behaving in the wild. This is where telemetry and monitoring come into play.

Telemetry is the automated process of collecting and transmitting data from remote sources to IT systems in a central location for monitoring and analysis. In the context of Business Central, telemetry allows you to peer into the "black box" of the SaaS environment. It informs you about performance bottlenecks, failed background jobs, runtime errors, and usage patterns. Without a robust telemetry strategy, you are essentially flying blind, reacting to customer support tickets rather than proactively resolving issues before they impact business operations.

For developers and system administrators preparing for the MB-820 exam, mastering telemetry is not just about passing a test; it is about building the capability to maintain high-quality solutions. This lesson will guide you through the architecture of Business Central telemetry, how to configure Application Insights, how to write custom telemetry, and how to interpret the data to keep your deployments stable and performant.

Not read yet

The Architecture of Business Central Telemetry

Business Central emits telemetry data natively from the platform. This data is structured and sent to an Azure Application Insights resource. You do not need to install agents on the servers; the platform handles the transmission automatically. Your primary responsibility is to create the destination (the Azure resource) and configure the environment to send data there.

The telemetry pipeline consists of three main components:

  1. The Source: The Business Central platform, which generates events such as web service calls, report execution, page loading, and long-running SQL queries.
  2. The Transport: The internal Microsoft pipeline that moves data from the Business Central service tier to your Azure Application Insights resource.
  3. The Destination: An Azure Application Insights resource where the telemetry data is stored, queried, and visualized using Kusto Query Language (KQL).

Understanding this flow is crucial for the MB-820 exam. You need to know that telemetry is not enabled by default for all environments. It must be explicitly configured in the Business Central Administration Center.

Callout: Telemetry vs. Logging While logging often refers to writing text-based files to a local disk (like traditional log files in an on-premises environment), telemetry in Business Central is structured, cloud-native, and queryable. Logs are often static records of events, whereas telemetry is a stream of data points designed for real-time analysis, alerting, and trend identification.

Not read yet

Setting Up Azure Application Insights

Before you can see any data, you must have a place to send it. Application Insights is a feature of Azure Monitor that provides extensible application performance management.

Step-by-Step Configuration:

  1. Create the Resource: Log into the Azure Portal and search for "Application Insights." Create a new resource. Ensure you select the correct region, although it does not strictly have to be the same region as your Business Central environment.
  2. Retrieve the Connection String: Once the resource is created, navigate to the "Overview" blade. Copy the "Connection String." This is the unique identifier that tells Business Central where to push your data.
  3. Configure Business Central: Open the Business Central Administration Center. Navigate to the "Environments" page. Select the specific environment you wish to monitor.
  4. Enter the String: Find the "Application Insights Connection String" field in the environment settings and paste the value you copied from the Azure Portal. Save your changes.

Note: Changes to the telemetry connection string in the Business Central Administration Center can take up to 30 minutes to propagate. Do not be alarmed if you do not see data immediately after hitting save.

Not read yet

Understanding the Telemetry Data Model

Once the connection is active, Business Central begins sending a variety of signals. These signals are categorized into specific event types. As a developer, you need to understand which signals are relevant to your work.

Common Telemetry Signals:

  • Runtime Errors: These are perhaps the most critical. They track AL runtime errors, including call stack information and the object that caused the error.
  • Web Service Requests: This tracks incoming and outgoing API calls. It includes information about the duration, the user, the object ID, and whether the call succeeded or failed.
  • Long-Running SQL Queries: Business Central tracks any SQL query that takes longer than a certain threshold. This is invaluable for identifying poorly optimized AL code that causes table locks or performance degradation.
  • Report Execution: Tracks which reports are run, how long they take, and if they were generated as a background task.
  • Extension Management: Logs when extensions are installed, uninstalled, or upgraded. This is useful for auditing environment changes.

Quick Reference Table: Telemetry Categories

Category Typical Use Case
Lifecycle Monitoring installation and update progress of extensions.
Performance Identifying slow queries or heavy web service traffic.
Stability Investigating runtime errors and crashes.
Security Tracking unauthorized access attempts or suspicious logins.
Usage Analyzing which pages or reports users are visiting most.

Not read yet

Custom Telemetry: Logging Your Own Events

While the platform provides excellent out-of-the-box telemetry, there are scenarios where you need to track custom business logic. For example, you might want to know how many times a specific "Calculate Commission" function is triggered or record the total value of sales orders processed by a specific custom integration.

Business Central provides the Session.LogMessage method for this purpose. This method allows you to push custom events into your Application Insights resource with your own metadata.

Example: Logging a Custom Business Event

procedure CalculateCommission(Amount: Decimal)
var
    CustomDimensions: Dictionary of [Text, Text];
begin
    // Perform your business logic here
    
    // Log the custom event to Application Insights
    CustomDimensions.Add('Category', 'CommissionCalculation');
    CustomDimensions.Add('Amount', Format(Amount));
    
    Session.LogMessage('COMM-001', 'Commission calculated successfully.', Verbosity::Normal, DataClassification::SystemMetadata, TelemetryScope::ExtensionPublisher, CustomDimensions);
end;

Explanation of LogMessage Parameters:

  1. Event ID: A unique string identifying the event. This helps you filter your logs in KQL.
  2. Message: A human-readable description of the event.
  3. Verbosity: Determines the severity of the log (e.g., Normal, Warning, Error, Critical).
  4. DataClassification: Ensures you are following compliance guidelines regarding PII (Personally Identifiable Information).
  5. TelemetryScope: Usually set to ExtensionPublisher to ensure the data is sent to your Application Insights resource.
  6. CustomDimensions: A dictionary where you can add extra context (key-value pairs) that will be searchable in Application Insights.

Warning: Never include sensitive data like clear-text passwords, credit card numbers, or personal health information in your custom telemetry messages or dimensions. Always sanitize your data before logging it.

Not read yet

Mastering Kusto Query Language (KQL)

The power of Application Insights lies in its query engine, KQL. Once data is flowing, you will use KQL to extract insights. For the MB-820 exam, you do not need to be a KQL expert, but you must understand the basic syntax to retrieve telemetry data.

Basic KQL Structure

A standard query starts with the table name (usually traces or dependencies), followed by a pipe (|) and operators.

Example: Finding Runtime Errors in your Extension

traces
| where customDimensions.eventId == 'LC0001' // Example event ID for runtime errors
| where customDimensions.extensionPublisher == 'YourCompany'
| project timestamp, message, customDimensions
| sort by timestamp desc

In this query, we filter the traces table for a specific event ID, restrict it to your publisher, and display the relevant columns. Understanding how to filter by customDimensions is the most important skill for a Business Central developer, as that is where your specific extension data lives.

Not read yet

Best Practices for Monitoring Extensions

Effective monitoring is a discipline, not a one-time setup. Follow these industry-standard best practices to ensure your monitoring strategy remains effective:

  1. Use Meaningful Event IDs: When writing custom logs, use a consistent naming convention for your Event IDs (e.g., APP-001, APP-002). This makes it significantly easier to create alerts and dashboards.
  2. Set Up Alerts: Do not wait to check your logs until a user reports an issue. Use the "Alerts" feature in Azure Monitor to send emails or trigger webhooks when specific conditions occur, such as a high rate of runtime errors.
  3. Monitor Performance Baselines: Before you deploy a new feature, observe the performance metrics of the environment. After deployment, compare the new telemetry against your baseline to see if the update introduced any regressions.
  4. Clean Up Old Data: Application Insights can become expensive if you store massive amounts of data for too long. Configure the data retention period based on your business requirements (usually 30-90 days is sufficient for operational debugging).
  5. Use Workbooks: Application Insights Workbooks allow you to create visual reports. Create a standard workbook for your team that displays top-level health indicators, such as daily active users, error rates, and average response times.

Not read yet

Common Pitfalls and How to Avoid Them

Even experienced developers can fall into traps when implementing telemetry. Here are the most common mistakes:

1. The "Silent Failure" Trap

Developers often wrap code in try...catch blocks or use if statements that suppress errors without logging them. If a background job fails silently, you will have no record of it in telemetry.

  • The Fix: Always ensure that if a process fails, you log the error. Even if you handle the error gracefully in the UI, log the technical details to telemetry so you can investigate the root cause later.

2. Excessive Logging (Log Spam)

Logging too much data inside a loop or a frequently triggered function can lead to "log spam," which makes it difficult to find meaningful data and can lead to performance degradation.

  • The Fix: Use appropriate verbosity levels. Reserve Critical or Error for actual failures. Use Normal or Verbose for informational messages, and only use Verbose for data that you only need during deep troubleshooting.

3. Ignoring Tenant-Level Telemetry

Sometimes, an issue is not with your extension, but with the underlying platform or a dependency. Many developers look only at their custom logs and ignore the platform logs.

  • The Fix: Familiarize yourself with the full suite of Business Central telemetry signals. Sometimes a slow report is caused by a system-wide platform update or an issue with an external API connection, rather than your AL code.

4. Hard-Coding Values

Hard-coding Event IDs or dimension names in your AL code makes it difficult to manage changes over time.

  • The Fix: Use a dedicated codeunit to handle telemetry logging. Define your Event IDs as constants within that codeunit. This creates a single point of truth and makes your code much easier to maintain.

Callout: Why Strategy Matters Telemetry is not just about catching errors; it is about understanding user behavior. By monitoring which pages are opened and which actions are clicked, you can make data-driven decisions about which features to improve or remove. This is the difference between a reactive support team and a proactive development organization.

Not read yet

Step-by-Step: Debugging a Real-World Issue

Let's walk through a common scenario: A customer reports that an integration with a shipping provider is timing out.

Step 1: Identify the scope Ask the customer for the time the issue occurred and the company name. This allows you to narrow down the search in your telemetry logs.

Step 2: Query for dependencies Use the dependencies table in KQL to look for outgoing web service calls to the shipping provider's URL.

dependencies
| where timestamp > ago(24h)
| where target == 'shipping-provider-api.com'
| project timestamp, success, resultCode, duration

Step 3: Analyze the results Look at the success column. If it shows false, check the resultCode (e.g., 404, 500, 401). If the duration is consistently high, you know you have a performance issue.

Step 4: Correlate with trace logs If you have custom telemetry in your integration code, use the correlationId to link the dependency call to your specific AL code execution.

traces
| where operation_Id == '<the-operation-id-from-dependency>'

Step 5: Resolve and Verify Once the issue is identified (e.g., an expired API key or a slow response from the provider), fix it and monitor the telemetry for the next 24 hours to ensure the success rate returns to 100%.

Not read yet

Advanced Telemetry: Dashboards and Visualization

While KQL is powerful for ad-hoc investigation, dashboards provide a high-level view of health. Azure Application Insights allows you to pin query results to a dashboard.

Creating a Health Dashboard:

  1. Develop the Query: Create a query that shows the number of runtime errors over the last 7 days.
  2. Pin to Dashboard: In the Application Insights interface, look for the "Pin to Azure dashboard" button.
  3. Organize: Group your pins by category (e.g., Performance, Errors, Usage).
  4. Share: Share the dashboard with your team. This provides a "single pane of glass" view where everyone can see if the system is healthy without needing to run individual queries.

Industry Standards and Compliance

When working with telemetry, you must respect privacy and compliance regulations like GDPR and HIPAA. Business Central provides the DataClassification property on all telemetry methods.

  • SystemMetadata: Use this for internal IDs, object names, and technical logs.
  • CustomerContent: If you must log business data, ensure it is classified correctly.
  • EndUserIdentifiableInformation: Avoid logging this whenever possible.

If you are a partner providing services to multiple customers, ensure that you are using separate Application Insights resources for each customer. This prevents cross-contamination of data and ensures that you are compliant with data isolation requirements.

Not read yet

Troubleshooting Telemetry Configuration

If you do not see data appearing in Application Insights, follow this checklist:

  1. Check Connection String: Is it formatted correctly? A common mistake is missing the InstrumentationKey or EndpointSuffix.
  2. Environment State: Is the environment active? Telemetry is only sent for active environments.
  3. Delay: Have you waited the full 30 minutes for the change to propagate?
  4. Telemetry Settings: Ensure that the telemetry level is set to "All" or an appropriate level in the Business Central Admin Center.
  5. Azure Permissions: Does your user account have the "Monitoring Contributor" role in the Azure resource? Without the correct permissions, you might not be able to view the data even if it is arriving.

Summary of Key Concepts for MB-820

To succeed on the MB-820 exam and in your professional work, keep these core principles in mind:

  • Telemetry is Native: Business Central does not require custom agents; it is built into the platform.
  • The Destination is Azure: Application Insights is the mandatory destination for Business Central telemetry.
  • KQL is Essential: You must be able to write basic queries to extract meaning from the telemetry stream.
  • Correlation is Key: Use operation_Id and customDimensions to track a request across different layers of the system.
  • Proactive vs. Reactive: Use alerts and dashboards to catch issues before your customers do.
  • Compliance Matters: Always be mindful of data classification and PII when logging custom events.
  • Standardization: Use consistent naming conventions for Event IDs and custom dimensions to make your logs predictable and searchable.

Not read yet

Conclusion

Telemetry and monitoring extensions represent a fundamental shift in how we manage Business Central solutions. By embracing these tools, you move from being a developer who "hopes" their code works to an engineer who "knows" their code is performing optimally. This level of visibility is what separates good solutions from great ones. As you prepare for the MB-820 exam, focus on the practical application of these concepts—don't just memorize the definitions, but try to imagine how you would use them to solve a real-world performance or stability issue. The ability to monitor, analyze, and optimize your cloud deployments is perhaps the most valuable skill you can develop in the modern Business Central ecosystem.


Frequently Asked Questions (FAQ)

Q: Can I send telemetry to multiple Application Insights resources? A: No, you can only configure one connection string per environment in the Business Central Administration Center.

Q: Does telemetry affect the performance of my extension? A: The overhead of sending telemetry is minimal, but logging excessively inside high-frequency loops can have a measurable impact. Always log strategically.

Q: How long is telemetry data stored in Application Insights? A: By default, it is 90 days, but you can configure this in the Azure Portal settings for your Application Insights resource to be as low as 30 days or as high as 730 days.

Q: Can I see telemetry for my local development environment? A: Telemetry is designed for SaaS environments. While you can technically point a Docker-based container to an Application Insights resource, it is primarily intended for production and sandbox environments in the cloud.

Q: What is the difference between TelemetryScope::ExtensionPublisher and TelemetryScope::All? A: ExtensionPublisher ensures the data is scoped to your publisher ID, while All allows for broader data collection, which is typically used by Microsoft or for cross-platform telemetry. For your own extensions, use ExtensionPublisher.

Not read yet

Each section gets a ✓ as you scroll through it. Tap the button to jump to the next one.