Table of Contents


Introduction

If you are a BizTalk Administrator and you are responsible of health and working of some BizTalk Server(s), then you must be a victim of a late night or weekend call asking you to have a look at the BizTalk Server as some services are down or not working properly;  And when you looked at the problem, it was as simple as “starting a Host Instance or Send Port which was stopped due to some network related issue”, you would love to have this small, portable, configurable, self-healing utility on your BizTalk Server(s) or on your own machine pointing to the BizTalk Server(s) you want to monitor. You can schedule it through Windows Task Scheduler as per your need and can save a lot of your time and energy.

Key Features

This utility provides multiple, completely configurable BizTalk Server Monitoring features:

  1. SQL Server Agent Service Check and Automatic Start
  2. SQL Server Agent Jobs Check and Automatic Enable
  3. Rule Engine Update Service Check and Automatic Start
  4. Host Instances Check and Automatic Start
  5. Orchestrations Check and Automatic Start
  6. Receive Locations Check and Automatic Enable
  7. Send Ports Check and Automatic Start
  8. Configure Excluded SQL Server Agent Jobs
  9. Configure Excluded Host Instances
  10. Configure Excluded Orchestrations
  11. Configure Excluded Receive Locations
  12. Configure Excluded Send Ports
  13. Sending Service Check Emails

Feature Details

Below are details of the features provided by the utility:

SQL Server Agent Service Check and Automatic Start

In this feature, utility checks the SQL Server Agent Service on the given BizTalk Server and if it found stopped, utility starts it automatically and write appropriate message in the email.

It write three types of messages against this check:

1. Service was already started

  • SQL Server Agent Service Check: SQL Server Agent Service on “Server Name” is started.

2. Service was stopped and started successfully

  • SQL Server Agent Service Check: SQL Server Agent Service on “Server Name” was stopped and has been started successfully.

3. Service was stopped and could not be started

  • SQL Server Agent Service Check: Could not start SQL Server Agent Service on “Server Name”.

In this case, another section will be added in the email with detailed exception occurred while trying to start the service. Exception section will look like as below:

*****************************************************************************************
The following exception(s) occurred during the checks: 
*****************************************************************************************

Permission is denied. The current user does not have sufficient permissions to perform this operation.
---------------------------------------

SQL Server Agent Jobs Check and Automatic Enable

In this feature, utility checks the SQL Server Agent Jobs (except the excluded jobs) on the given SQL Server (SQL Server on which BizTalk is configured) and if any jobs are disabled, utility enables them automatically and write appropriate message in the email.

It write three types of messages against this check:

1. Agent Jobs were already enabled

  • SQL Server Agent Check: The SQL Server Agent check succeeded on DEV Server (“Server Name\Instance”).

2. Agent Jobs were disabled and enabled successfully

  • SQL Server Agent Check: The SQL Server Agent check succeeded on DEV Server (“Server Name\Instance”).
    The following SQL Server Agent Job(s) were found disabled on DEV Server (“Server Name\Instance”) and successfully enabled: 
    Backup BizTalk Server (BizTalkMgmtDb) 
    TrackedMessages_Copy_BizTalkMsgBoxDb
    Rules_Database_Cleanup_BizTalkRuleEngineDb

3. Agent Jobs were disabled and could not be enabled

  • SQL Server Agent Check: The following SQL Server Agent Job(s) are found disabled on DEV Server (“Server Name\Instance”).
    Backup BizTalk Server (BizTalkMgmtDb) 
    TrackedMessages_Copy_BizTalkMsgBoxDbRules_Database_Cleanup_BizTalkRuleEngineDb
    Only “enabled jobs count” Job(s) are reported to be running on DEV Server (“Server Name\Instance”)

In this case, another section will be added in the email with detailed exception occurred while trying to enable the jobs. Exception section will look like as bellow:

*****************************************************************************************
The following exception(s) occurred during the checks: 
*****************************************************************************************

Permission is denied. The current user does not have sufficient permissions to perform this operation.
---------------------------------------

Rule Engine Update Service Check and Automatic Start

In this feature, utility checks the Rule Engine Update Service on the given BizTalk Server and if it found stopped, utility starts it automatically and write appropriate message in the email.

It write three types of messages against this check:

1. Service was already started

  • Rule Engine Update Service Check: Rule Engine Update Service on “Server Name” is started.

2. Service was stopped and started successfully

  • Rule Engine Update Service Check: Rule Engine Update Service on “Server Name” was stopped and has been started successfully.

3. Service was stopped and could not be started

  • Rule Engine Update Service Check: Could not start Rule Engine Update Service on “Server Name”.

In this case, another section will be added in the email with detailed exception occurred while trying to start the service. Exception section will look like as bellow:

*****************************************************************************************
The following exception(s) occurred during the checks: 
*****************************************************************************************

Permission is denied. The current user does not have sufficient permissions to perform this operation.
---------------------------------------

Host Instances Check and Automatic Start

In this feature, utility checks the Host Instances on the given BizTalk Server and if they found stopped, utility starts them automatically and write appropriate message in the email.

It write three types of messages against this check:

1. Instances were already started

  • BizTalk Servers Check: All Host Instances are started.

2. Instances were stopped and started successfully

  • BizTalk Servers Check: The following Host Instances were found stopped and successfully started: 
    • Microsoft BizTalk Server BizTalkServerApplication LHRLT-123

3. Instances were stopped and could not be started

  • BizTalk Servers Check: The following Host Instances were found stopped and can not be started. Manual start needed: 
    • Microsoft BizTalk Server BizTalkServerApplication LHRLT-123

In this case, another section will be added in the email with detailed exception occurred while trying to start the Host Instances. Exception section will look like as bellow:

*****************************************************************************************
The following exception(s) occurred during the checks: 
*****************************************************************************************

Permission is denied. The current user does not have sufficient permissions to perform this operation.
---------------------------------------

Orchestrations Check and Automatic Start

In this feature, utility checks the Orchestrations on the given BizTalk Server and if they found stopped, utility starts them automatically and write appropriate message in the email.

It write three types of messages against this check:

1. Orchestrations were already started

  • BizTalk Servers Check: All Orchestrations are started.

2. Orchestrations were stopped and started successfully

  • BizTalk Servers Check: The following Orchestrations were found stopped and successfully started: 
    • Orchestration123

3. Orchestrations were stopped and could not be started

  • BizTalk Servers Check: The following Orchestrations were found stopped and can not be started. Manual start needed:
    • Orchestration123

In this case, another section will be added in the email with detailed exception occurred while trying to start the Orchestrations. Exception section will look like as bellow:

*****************************************************************************************
The following exception(s) occurred during the checks: 
*****************************************************************************************

Permission is denied. The current user does not have sufficient permissions to perform this operation.
---------------------------------------

Receive Locations Check and Automatic Enable

In this feature, utility checks the Receive Locations on the given BizTalk Server and if they found stopped, utility starts them automatically and write appropriate message in the email.

It write three types of messages against this check:

1. Receive Locations were already started

  • BizTalk Servers Check: All Receive Locations are started.

2. Receive Locations were stopped and started successfully

  • BizTalk Servers Check: The following Receive Locations were found stopped and successfully started:
    • ReceiveLocations_Test

3. Receive Locations were stopped and could not be started

  • BizTalk Servers Check: The following Receive Locations were found stopped and can not be started. Manual start needed:
    • ReceiveLocations_Test

In this case, another section will be added in the email with detailed exception occurred while trying to start the Receive Locations. Exception section will look like as bellow:

*****************************************************************************************
The following exception(s) occurred during the checks: 
*****************************************************************************************

Permission is denied. The current user does not have sufficient permissions to perform this operation.
---------------------------------------

Send Ports Check and Automatic Start

In this feature, utility checks the Send Ports on the given BizTalk Server and if they found stopped, utility starts them automatically and write appropriate message in the email.

It write three types of messages against this check:

1. Send Ports were already started

  • BizTalk Servers Check: All Send Ports are started.

2. Send Ports were stopped and started successfully

  • BizTalk Servers Check: The following Send Ports were found stopped and successfully started:
    • SendPort_Test
    • SendPort_Test1

3. Send Ports were stopped and could not be started

  • BizTalk Servers Check: The following Send Ports were found stopped and can not be started. Manual start needed:
    • SendPort_Test
    • SendPort_Test1

In this case, another section will be added in the email with detailed exception occurred while trying to start the Send Ports. Exception section will look like as bellow:

*****************************************************************************************
The following exception(s) occurred during the checks: 
*****************************************************************************************

Permission is denied. The current user does not have sufficient permissions to perform this operation.
---------------------------------------

Configure Excluded Agent Jobs

Using this feature, you can add quote comma quote (‘,’) separated list of SQL Server Agent Job names which should be excluded from the SQL Server Agent Jobs Check.

e.g. "Monitor BizTalk Server (BizTalkMgmtDb)','DTA Purge and Archive (BizTalkDTADb)"

Configure Excluded Host Instances

Using this feature, you can add comma separated list of fully qualified names of Host Instances which should be excluded from the Host Instances Check.

e.g. "Microsoft BizTalk Server Host_Excluded LHRLT-123" where "Host_Excluded" is Host Instance Name and "LHRLT-123" is BizTalk Server name.

Configure Excluded Orchestrations

Using this feature, you can add comma separated list of Orchestration names which should be excluded from the Orchestrations Check.

Configure Excluded Receive Locations

Using this feature, you can add comma separated list of Receive Location names which should be excluded from the Receive Locations Check.

Configure Excluded Send Ports

Using this feature, you can add comma separated list of Send Port names which should be excluded from the Send Ports Check.

Sending Service Check Emails

This is most import feature of the utility by which it sends all the details of the checks performed. It sends emails with two possible subjects:

1. BizTalk Automated Health Check Notification – OK

If all the checks are successful and no exceptions occurred, then the email is sent with the following subject:

  • LHRLT-427 - BizTalk Automated Health Check Notification - OK

Service Check OK email will look like as below:

2. BizTalk Automated Health Check Notification - PROBLEM FOUND

If any of the checks are unsuccessful or any exceptions occurred, then the email is sent with the following subject:

  • *** LHRLT-427 - BizTalk Automated Health Check Notification – PROBLEM FOUND ***

Service Check PROBLEM FOUND email will look like as below:

Building the Sample

Below are the steps to build this sample (If you don't want to build the code, two ready to use exes compiled with .NET Framework 4.5 and 2.0 are already placed in "\BizTalkMonitoringAutomation\PortableUtility\" folder):

  1. Download “BizTalkMonitoringAutomationUtility.zip” file
  2. Unzip the file
  3. Open “BizTalkMonitoringAutomation.sln” in Visual Studio 2012
  4. Right click and Build the solution
  5. Go to “\BizTalkMonitoringAutomation\bin\Debug” folder
  6. Copy portable exe file “BizTalkMonitoringAutomation.exe” and place on any required location. e.g. "C:\BTMon\"
  7. Copy the configuration file “BizTalkMonitoringAutomation.exe.config” from “\BizTalkMonitoringAutomation\PortableUtility\4.5” or “\BizTalkMonitoringAutomation\PortableUtility\2.0” or create your own as per the given sample and place it in the same folder with the portable exe file

Below is the overview of the only class in the code:

How to Configure?

There are configuration files along with the portable exes in "\BizTalkMonitoringAutomation\PortableUtility\" folder. Below is a sample of configuration file:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <appSettings>
    <!-- Servers Settings: -->
    <!-- Add your BizTalk Server Name. It is required. -->
    <add key="BizTalkServer1" value="LHRLT-123"/>
    <!-- Add your Secondary BizTalk Server Name if you are in multi-server environment or leave it empty. -->
    <add key="BizTalkServer2" value=""/>
    <!-- NOTE: Any one of DEV, QA, IT or PROD SQL Server is required. -->
    <!-- Add your Development SQL Server Name\Instance or leave it empty. -->
    <add key="DEV" value="LHRLT-123\MSSQLSERVER2012"/>
    <!-- Add your Testing SQL Server Name\Instance or leave it empty. -->
    <add key="QA" value=""/>
    <!-- Add your UAT SQL Server Name\Instance or leave it empty. -->
    <add key="IT" value=""/>
    <!-- Add your Production SQL Server Name\Instance or leave it empty. -->
    <add key="PROD" value=""/>
    <!-- Service/Job Checks Settings: -->
    <!-- Set "Y" to enable SQL Server Agent Service check or set "N" to disable the check -->
    <add key="SqlAgentServiceCheckEnabled" value="Y"/>
    <!-- Set "Y" to enable SQL Server Agent Jobs check or set "N" to disable the check -->
    <add key="SqlAgentJobCheckEnabled" value="Y"/>
    <!-- Set value "Y" to enable Rule Engine Update Service check or set "N" to disable the check -->
    <add key="RuleEngineUpdateServiceCheckEnabled" value="Y"/>
    <!-- Set value "Y" to enable Host Instances check or set "N" to disable the check -->
    <add key="HostsCheckEnabled" value ="Y"/>
    <!-- Set value "Y" to enable Orchestrations check or set "N" to disable the check -->
    <add key="OrchsCheckEnabled" value ="Y"/>
    <!-- Set value "Y" to enable Receive Locations check or set "N" to disable the check -->
    <add key="ReceiveLocationsCheckEnabled" value ="Y"/>
    <!-- Set value "Y" to enable Send Ports check or set "N" to disable the check -->
    <add key="SendPortsCheckEnabled" value ="Y"/>
    <!-- Configuring Excluded Lists: -->
    <!-- Add quote comma quote separated list of SQL Server Agent Job names which should be excluded from the check or leave it empty.
         e.g. "Monitor BizTalk Server (BizTalkMgmtDb)','DTA Purge and Archive (BizTalkDTADb)" -->
    <add key="ExcludedAgentJobs" value="Monitor BizTalk Server (BizTalkMgmtDb)','DTA Purge and Archive (BizTalkDTADb)','MessageBox_Message_ManageRefCountLog_BizTalkMsgBoxDb"/>
    <!-- Add comma separated list of fully qualified names of Host Instances which should be excluded from the check or leave it empty
         e.g. "Microsoft BizTalk Server Host_Excluded LHRLT-123" where "Host_Excluded" is Host Instance Name and "LHRLT-123" is BizTalk Server name. -->
    <add key="ExcludedHosts" value ="Microsoft BizTalk Server Host_Excluded LHRLT-123"/>
    <!-- Add comma separated list of Orchestration names which should be excluded from the check or leave it empty -->
    <add key="ExcludedOrchs" value =""/>
    <!-- Add comma separated list of Receive Location names which should be excluded from the check or leave it empty -->
    <add key="ExcludedReceiveLocations" value ="ReceiveLocation_Excluded1,ReceiveLocation_Excluded2"/>
    <!-- Add comma separated list of Send Ports names which should be excluded from the check or leave it empty -->
    <add key="ExcludedSendPorts" value ="SendPort_Excluded"/>
    <!-- Email Settings: -->
    <!-- Set your SMTP Server. -->
    <add key="SMTPServer" value ="smtp.yourdomain.com"/>
    <!-- Set your SMTP Port. -->
    <add key="SMTPPort" value="25" />
    <!-- Set your SMTP User. -->
    <add key="SMTPUser" value="username" />
    <!-- Set your SMTP Password. -->
    <add key="SMTPPassword" value="password" />
    <!-- Set value "true" or "false" as required by your SMTP Server. -->
    <add key="SMTPEnableSsl" value="false" />
    <!-- Set value "true" or "false" as required by your SMTP Server. -->
    <add key="SMTPUseDefaultCredentials" value="false" />
    <!-- Add comma separated list of email accounts who are sending this email. At least one account is required. e.g. SrvsCheck@YourDomain.com -->
    <add key="FromEmail" value="SrvsCheck@YourDomain.com"/>
    <!-- Add comma separated list of email accounts who should get this email. At least one account is required. -->
    <add key="ToEmail" value="youremail1@yourdomain.com,youremail2@yourdomain.com"/>
    <!-- Add comma separated list of email account(s) who are oncall for production support or leave it empty. Add OnCall list only in case of Production Server. -->
    <add key="OnCall" value =""/>
  </appSettings>
</configuration>

How to Use?

Best way to use this utility is to configure it with Windows Task Scheduler. Below are the steps to configure it with a Windows Task Scheduler:

  • Open Windows Task Scheduler
  • Right click the Task Scheduler Library and click New Folder

  • Create new folder with the name BizTalk

  • Now right click BizTalk folder and click Create Task...

  • Do the following settings on General tab. Set User as per your environment

  • Go to Triggers tab and add a new trigger

  • Go to Actions tab and add a new action as per your requirement

  • Go to Conditions tab and set the conditions as per your requirement or leave it with default settings

  • Go to Settings tab and configure as per your requirement or leave it with default settings

        

  • Leave the History tab as it is

        

  • Enable the Task and you are done

  • Check the History for a successful run

Source Code

Source Code for this article can be downloaded at the MSDN Code Gallery: BizTalk Monitoring Automation Utility

See Also

Another important place to find a huge amount of BizTalk related articles is the TechNet Wiki itself. The best entry point is BizTalk Server Resources on the TechNet Wiki.

view counter