Business Central Musings

For the things we have to learn before we can do them, we learn by doing them

Send Business Central environment notifications to Teams

Share This Post

Most professionals working with BC online are receiving notifications of environment changes via email. But did you know that is possible to receive Business Central environment notifications on your Teams app?

In this blog post I will dive into 2 Microsoft Azure Logic App samples for sending notifications to Teams when BC environments get deleted and when BC environments fail to update.

In my previous blog post I looked at all communication channels provided by Microsoft to acknowledge certain users of various changes in Business Central environments.

I looked at Business Central Admin Center, with the Notification Recipients page for adding new emails to mass notifications, or Operations blade for environment and apps changes.

Another section in my previous blog post speaks about notifications delivered via Message Center and Health Services within Microsoft 365 Admin Center.

I also highlighted the most comprehensive piece offered by Microsoft to log BC operations internally and at environment level. I am referring here to Application Insights logs emitted by Microsoft while running internally various processes or changes triggered by users or Microsoft tasks to change environments (copy, delete environments, database export, AppSource apps installs, AppSource updates).

One way of delivering these environment changes is via Azure services like Logic Apps.

Microsoft has a few samples for sending Teams notifications when something happens to a Business Central environment.

One example is sending Teams notifications on deleted environments.

A second example is capturing in Teams failed environment updates.

Here is the link to the Microsoft documentation.

Example 1: Business Central environment notifications to Teams for deleted environment

Microsoft shared templates for sending Teams messages when a Business Central environment is removed.

When an environment gets deleted, either through a manual user-initiated action or via a Business Central Admin Center API request (as I explained here), a telemetry log gets created in Application Insights.

Microsoft notification template includes a Logic App whose main reason for operating is to:

  • trigger every 15 minutes (but you can adjust the recurrence),
  • query traces table for logs related to environment deletions,
  • for each such log, send a Teams message to the recipient of notifications.

Let’s explore the template and talk through what it does.

Notification template

To start with building a notification for deleted environments you would need the following:

  • access to an Azure Portal with an Application Insight service
  • a BC environment connected to the Azure Application Insight so that everything you do in Business Central (app or environment) logs in Azure Application Insights. If you did not connect Business Central environments to telemetry logs in Application Insights, you can start here.
  • notification recipients have a Teams license

Let’s start.

Visit Microsoft page, and click on Deploy to Azure:

or click here.

Template content

The template link brings us to Azure Portal on a Custom Deployment page:

You should see something like below when finished:

Navigating to the new resources group we can see the services created:

What we get is a Logic App and 2 connectors, one for Application Insights Service and one connector for Microsoft Teams. Each connector needs to be setup.

First, for applicationinsights API connection, make sure you create an API key and add its values to the connection:

Secondly, for Teams API connection, add your Teams’ email and hit Authorize button:

Functionality and outcome

The Logic App looks like this:

It is triggered by a recurrence trigger, runs a KQL query based on traces table, and for each record found sends a message to recipient’s Teams account.

  • The Logic App starts (triggered) with a Recurrence trigger and is trigger every 15 minutes.
  • The core of the logic app is running an analytics query:

The App Insights traces log we are hunting for is a log with eventid = ‘LC0150’.

  • For each identified log, the logic app will post a message in the recipient’s Teams channel:

In Business Central Admin Center I deleted an environment that has Telemetry turned on and checking for the log by querying the traces table reveals the event:

You can wait for next run of the Logic App or enforce the trigger with Run Trigger. The end result is a chat message posted as a Flow Bot in my Teams client:

Example 2: Business Central environment notifications to Teams when an environment update fails

On the same Microsoft Learn page there is an additional template for email notifications when environment updates fail.  With minimal effort we can turn that into a Teams notification.

After validating and executing the template, you will need to add a connector to Teams and Authorize it. Your Power Logic App should look like this:

A few weeks ago, I had an environment that failed an update and received an email. Modifying the query to run over a longer period of time allows capturing the event I was looking for:

And after triggering the Logic App manually, we get the Teams message:


To receive notifications via Logic Apps assumes you implemented telemetry on your BC environments. Turning telemetry on (i.e., turning Application Insights service on), comes with a cost and the cost of running Application Insights service has two major components:

  • how much data is ingested.
  • how long data is retained.

If you want to have a look at the Application Insights costs, please visit this Microsoft Azure page.

Running a Logic App in Azure comes with costs as well. The cost is dependent on:

  • number of actions executed within the Logic App
  • number of connections
  • number of runs (how often is triggered)

Read this to find out details.

Additionally, you could give a read Stefano’s blog on costs related to Application Insights.


I covered in this blog post two Microsoft examples of Logic Apps, that get triggered regularly and interrogate Applications insights looking for specific events. Once found, the Application Insight records get parsed and sent via a Flow Bot to Microsoft Teams.

The same page contains two more examples of grouping environment updates and sending notifications to Teams and, posting adaptive cards to Teams for each available update. Thankfully, implementing these notifications is fairly straightforward, and it can be implemented with no code and minimal set up.

I invite you to have a look and give it a shot.

Share This Post

Related Articles

One Response

Leave a Reply

Recent Posts

Get Notified About New Posts

Verified by MonsterInsights