Introducing the PowerShell Notification Channel in BizTalk360

Published on : Oct 16, 2018

Category : BizTalk360 Update

rochelle

Author

Notifications are an established concept for alerting users. By default, a number of external notification channels are inbuilt into BizTalk360. The only step you need to do, is to configure these notification channels with the appropriate URL, Access Token value (for Slack) and Authentication settings (for ServiceNow and WebHook), and Teams WebHook Connector (for Microsoft Teams). What this means for you, is that if you are already using either of these channels in your organization, it becomes easier to receive alerts from BizTalk360 right into these channels.

Since previous versions of BizTalk360, the notifications from BizTalk360 can be sent through various channels like:

Besides the above mentioned channels, BizTalk360 also provides an easy to use API, to enable you to create notification channels for connecting to your own systems. Read more about creating your own custom notification channels in our Documentation portal.

Now, integration with PowerShell allows you to execute a PowerShell script, each time an alarm is triggered when the threshold is crossed.

This was one of the features most requested by customers, as a nice to have requirement, as it would enable them to perform some tasks via a PowerShell script, each time the alarm was triggered.

Steps to implement the PowerShell Notification Channel

It only takes a few steps to use the PowerShell Notification Channel:

  • Create the PowerShell script
  • Configuring the PowerShell Notification Channel in BizTalk360

Both steps are explained below.

Create the PowerShell script

  1. Create the script in the PowerShell ISE or a plain text editor such as Notepad and save it with a .PS1 file extension (for example, myscript.ps1)
  2. Run the script by entering the full path to the script (c:/scripts/myscript.ps1), or if it’s in the current directory, prefix it with a period followed by a slash ( ./myscript.ps1 )

Configuring the PowerShell Notification Channel in BizTalk360

  • You can find the Powershell Notification Channel under Settings > Monitoring and Notification > Manage Notification Channels. Select Notifier.PowerShellNotification
  • Click “Configure” to open the configuration panel

PowerShell Notification Channel: Configuring the channel

During the configuration, provide the path along with the file name where the PowerShell script is present.

  • In the Alarm section (Monitoring -> Manage Alarms), when you edit the alarm, enable the PowerShell notifications channel using the slider.

Note: Unless you wish to override the script provided in the settings page, there is no need to provide the path once again

PowerShell Notification Channel: Enable in an alarm

Whenever a violation appears for the given alarm, this will trigger the notification channel and it will hit the PowerShell script. 

Here, in the sample PowerShell script(Restart.ps1), we have included some basic code to restart the BizTalk360 Analytics service, but you can include more complex code to perform any actions via a Powershell script.

Customer Scenarios

  • Use case 1: Automatically disable a receive location, such as when suspended instances hit a certain threshold

Consider the following setup – Microsoft CRM plugins, connected to a Receive Location are failing periodically. When they are down, the customer gets flooded with suspended instances. To prevent this from happening, the user wants to Disable the Receive Location.

This is how we can implement this using BizTalk360.

  1. Configure the PowerShell notification Channel
  2. First, create a Threshold alarm and setup the notification channel to be PowerShell, providing the script name if you wish to override the default Powershell script provided
  3. Then, in Manage Mapping, select the alarm and the artifact – Suspended Instances and put our threshold which causes the alarm to trigger

PowerShell Notification Channel: Manage alarms

Now when the alarm triggers, along with the default email notification, the PowerShell script which disables the receive location mentioned in the script, will be run. Any errors will be logged in the PowerShell notification channel log (External.log).

  • Use case 2: Stopping Host Instances, in case of too many running instances

A customer uses Data Monitoring for monitoring running instances of a particular orchestration in BizTalk. Sometimes it occurs that the application generates more messages than the downstream system can handle. To prevent damage, the Host Instances which serve the BizTalk application, need to be stopped to be able to identify the root cause.

The PowerShell notification channel not just works with Threshold alarms, but also based on Data Monitors. In above scenario, a Message Box Data Monitor has been setup, but you could also trigger PowerShell scripts based on the other categories of Data Monitoring. This could make the PowerShell notification channel to a strong extension of your tool set.

  • Use case 3: We could fire a PowerShell script to restart IIS

We can implement these scenarios using BizTalk360 using similar steps as scenario1 but now the Alarm will be a Threshold alarm, not on Application artifacts but in BizTalk Environment -> Web Endpoint Monitoring.

Like scenario1 the alarm will have PowerShell notification enabled and when the Web end-point is triggered when the response is not fast enough, the Powershell script will run and restart the windows service (This should be programmed in the .ps1 file)

So, I hope these scenarios gave you a good idea of how the PowerShell notification channel can help you. This can also be considered as an action to be carried out if the alarms are triggered.