Tuesday, October 11, 2011

BizTalk BAM Request Technical Assistance Email Alert

I am still not heavily invested in SCOM and needed a quick and easy way to set an email alert anytime a user requested technical assistance from BAM portal.By default, the Request Technical Assistance functionality creates an entry only in the Event Viewer of the BizTalk Server where BAM portal is hosted.
Below is the code snippet required to add the technical assistance request to event log:

BufferedEventStream eventStream = new BufferedEventStream(connstring, 0);
eventStream.AddReference("My Activity", ActivityID, "BizTalkService", "Biztalk Service ID of this message:" + messageID, messageID);
eventStream.AddReference("My Activity", ActivityID, "MessageId", "Biztalk Message ID of this message:" + messageID, messageID);

The above code snippet helps write to the event log when a user submits request technical assistance on BAM portal.It writes EventID 1000 with the source BAM Web Services as shown below:













Now we need to attach a custom task to this event in event log.
Here is how we can achieve it :
1. Open Event Viewer, browse to Custom views
2. Create a custom view with the properties below:


3. Under Actions, select Attach Task To This Event
4. This will open the wizard to Create a basic Task, follow the wizard to create the task with the action to Send an email.
5. This will enable sending a blank email whenever the event above is logged. But we need the event details in the email.
6. Then i came across this little gem : Wevtutil.
7. I used the blog here to achieve the desired functionality of adding the content of event log as attachment to the email.
8. This is how my batch file looks like:
del "C:\temp\bamquery.txt"
wevtutil qe Application "/q:*[System[(EventID=1000)]]" /f:text /rd:true /c:1 > "C:\temp\bamquery.txt"
9. Finally the task under Server Manager shows the task with 2 actions:













That's it! Now every-time a user requests technical assistance on BAM portal an email is sent to the support personnel with the description and BizTalk Message ID.

No comments:

Post a Comment