As a BizTalk administrator, you need to know about any issues in your BizTalk environment. It is crucial to know about these issues before they become real problems or cause any unnecessary outage for any integration services provided by your BizTalk server.
In this article I will demonstrate an easy way to send alerts in case there are any errors or warnings in the BizTalk environment.
You may have some customers connecting to your integration middleware through receive adapters, such as POP3, SFTP, FTP, File, etc. In some cases you may get some warnings and errors which affect these receive adapters and make them disabled once the error threshold is exceeded.
In many instances, you would not be able to use the BizTalk Administration Console for alerting as these entries do not even register in the BizTalk Message Box.
Therefore, it is very important to be notified before the end users prompted with warning or error messages when they are trying to upload into integration middleware. It is equally important to take a proactive approach to resolve any upcoming issues you might be experiencing with your BizTalk server.
If your project does not have a budget to deploy these motioning tools, there is an easy way to get BizTalk alerts by using a combination of PowerShell scripting and the built-in Windows Task Scheduler through the following steps:
- Select Windows Start Button ->Control Panel->Administrative Tools -> Task Scheduler as shown in Figure 1 or use the shortcut command in run window control schedtasksFigure 1. Accessing Task Scheduler
- In Task Scheduler window, select Microsoft folder->click on create task -> in General Tab Name the task as shown in Figure 2Figure 2. Create Task
- Select Trigger Tab->Click New button-> in the Begin the task select on an event ->select custom->click New Event Filter button-> in Event Sources select BizTalk -> In case you want to filter by using event id you can set an event id as shown in Figure 3Figure 3. Create Trigger
- Select Action Tab->Click New Button->In Action select Send an e-mail->set email settings properties as shown in Figure 4Figure 4. Create Exchange Email Action
- If you want to add attachment of event logs to be included in email, then you need to create a new action to run the following command which write your filter log into a text file in my case I filtered on EventId 5740 which is pop3 warning that happens once pop3 user not authenticated and save it in this path C:\SendEmail\temp\logs.txt
wevtutil qe Application
/f:text /rd:true /c:1> C:\SendEmail\temp\logs.txt
- Save command into cmd file and rename it into path C:\SendEmail\WriteLog.cmd
- Create new action -> In Action field, select start a program-> Set Program/Script Path as shown in Figure 5Figure 5. Create Command Action
- Sort action and make sure that running the command action in the first action as shown in Figure 6Figure 6. Sort actions
- In case you do not want to use exchange mail server, then you can write the following powershell script and save it in this path C:\SendEmail\SendEmailScript.ps1
System.Net.Mail.MailMessage( $emailFrom , $emailTo )
<p>There is a BizTalk issue</p>
<p>Check the attachment</p>
System.Net.Mail.SmtpClient( $emailSmtpServer , $emailSmtpServerPort )
System.Net.NetworkCredential( $emailSmtpUser , $emailSmtpPass );
$SMTPClient.Send( $emailMessage )
- Create another command file to run powershell script as below and save it in this path C:\SendEmail\RunPowerShellScript.cmd
powershell C:\SendEmail\SendEmailScript.ps1Now SendEmail folder should be as shown in Figure 7
Figure 7. Files inside SendEmail Folders
- Update Send Email Action which we created in step 4 to run a program with path C:\SendEmail\RunPowerShellScript.cmd as shown in
Figure 8. Edit Action to use PowerShell script
- To test your work, create pop3 receive location and set a wrong username and password