This helps to automate a part of BizTalk monitoring activity, ideally monitoring BizTalk artifacts status. Below steps helps you if you are setting up email alerts for your support group when things to wrong.
BizTalk server uses SQL database BizTalkMgmtDb to store all information about the BizTalk Server environment.
SQL server trigger on the table related to the artifacts will be used to detect status change.
Below steps describes step by step process.
Below steps shows Database Mail Configuration Wizard to create a SQL Server mail profile, but you can use Transact-SQL too.
EXEC
msdb.dbo.sp_send_dbmail
@profile_name =
'BizTalkSupportUser_Profile'
,
@recipients =
'supportgroup@MyOrg.com'
@body =
'The stored procedure finished successfully.'
@subject =
'Automated Success Message'
;
Execute below T-SQL to create a trigger in Management Database to detect Receive Location status change
IF OBJECT_ID (
'ReceivePortChangeNotification'
'TR'
)
IS
NOT
NULL
DROP
TRIGGER
ReceivePortChangeNotification;
GO
CREATE
ReceivePortChangeNotification
ON
BizTalkMgmtDb..adm_ReceiveLocation
AFTER
UPDATE
AS
if((
select
Disabled
from
inserted) <> ((
deleted)))
BEGIN
DECLARE
@NewLineChar
VARCHAR
(5)=
'<br/>'
@
To
as
(255) =
'biztalksupportteam@MyOrg.com'
@Subject
(255)
@Body
@ReceiveLocationName
@Status
varchar
(10)
@DateModified datetime
SELECT
@ReceiveLocationName =
name
, @DateModified = DateModified, @Status =
CASE
WHEN
[Disabled]=0
THEN
'Enabled'
[Disabled]=-1
'Disabled'
END
inserted;
SET
@Subject =
'BizTalk ReceiveLocation "'
+ @ReceiveLocationName +
'" Status Changed Notification!'
@Body =
'Dear Support,'
+ @NewLineChar +
'Please be adviced that the status of the receive location in subject line has been changed on: '
+
convert
(
(25), @DateModified) + @NewLineChar +
'New status is: '
Varchar
, @Status) + @NewLineChar +
'Take an appropriate action!'
'Kind Regards'
'BizTalk Server'
@recipients = @
@body = @Body,
@subject = @Subject,
@body_format=
'HTML'
Execute below T-SQL to create a trigger in Management Database to detect Send Port status change
'SendPortChangeNotification'
SendPortChangeNotification;
SendPortChangeNotification
BizTalkMgmtDb..bts_sendport
nportStatus
@SendPortName
@SendPortName = nvcName, @DateModified = DateModified, @Status =
nportStatus=1
'Unenlisted'
nportStatus=2
'Stopped'
nportStatus=3
'Started'
'BizTalk SendPort "'
+ @SendPortName +
'Please be adviced that the status of the sendport in subject line has been changed on: '
You can extend this functionality to monitor Orchestration status change on table bts_orchestration with column nOrchestrationStatus, Sendport group on table bts_sendportgroup with nPortStatus.
If you have implemented this above in non production system (like QA, STG) you can try changing the receive location and/or send port and refresh the mailbox (biztalksupportteam@MyOrg.com).