Personalized Community is here!
Quickly customize your community to find the content you seek.
Check out the latest Business Central updates!Learn about the key capabilities and features of Dynamics 365 Business Central and experience some of the new features.
Overview | Guided Tour | Free Trial
2023 Release Wave 1Check out the latest updates and new features of Dynamics 365 released from April 2023 through September 2023
The FastTrack program is designed to help you accelerate your Dynamics 365 deployment with confidence.
FastTrack Community | FastTrack Program | Finance and Operations TechTalks | Customer Engagement TechTalks | Upcoming TechTalks | All TechTalks
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.
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:
Let’s explore the template and talk through what it does.
To start with building a notification for deleted environments you would need the following:
Visit Microsoft page, and click on Deploy to Azure:
or click here.
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:
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 App Insights traces log we are hunting for is a log with eventid = ‘LC0150’.
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:
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:
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:
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.
The post Send Business Central environment notifications to Teams appeared first on Business Central Musings.
Business Applications communities