venneker.net

.NET, BIZTALK, ESB, AZURE

Category: BizTalk (page 1 of 17)

Remove BizTalk orphans from tracking

Here a SQL Script to remove orphans from your BizTalk tracking. It sets an end date so they can be removed.

USE [biztalkDTADb]


UPDATE
    [dbo].[dta_ServiceInstances]

SET
    [dtEndTime] = GetUTCDate()
WHERE
    dtEndTime is NULL
    AND
    [uidServiceInstanceId] NOT IN
    (
    SELECT
        [uidInstanceID]
    FROM
        BizTalkMsgBoxDb.[dbo].[Instances] WITH (NOLOCK)
    UNION
    SELECT
        [StreamID]
    FROM
        BizTalkMsgBoxDb.[dbo].[TrackingData] WITH (NOLOCK)
    )

Lost admin rights on SQL Server

If you somehow lost your admin right on your dev SQL Server, here’s how you can add the logged in user account again.

You will have to start SQL Server in single user mode and than add the local account in the sysadmin role.

Start SQL Single user:
SQLServr.Exe –m

Add your account:
SQLCMD
1> SP_ADDSRVROLEMEMBER ‘’,’SYSADMIN’
2>go

Enable all tracking on everything

This is a script I use often. It was initially created by Sandro Pereira and modified by Matt Corr. This is great to set everything enabled on your dev machine.

Here a copy of the script:

<#
    .SYNOPSIS
        This script will update a defined list of BizTalk Application's tracking settings to be enabled or disabled for all Orchestrations, Send/ReceivePorts, Pipelines and Schemas.
    .DESCRIPTION
        This script is based on one originally created by Sandro Pereira which was obtained from here:
        http://sandroaspbiztalkblog.wordpress.com/2014/11/03/biztalk-devops-how-to-take-control-of-your-environment-disable-tracking-settings-in-biztalk-server-environment/
        I have extended it to update tracking settings to be enabled or disabled for a definable list of matching BizTalk applications. 

    .PARAMETER NameLike
        The optional Parameter that provides a LIKE clause for the BizTalk application Name. If ommitted, then all BizTalk applications will have their tracking updated.

    .PARAMETER SetTracking
        Can be either True or False. Determines if tracking is to be enabled or disabled

    .EXAMPLE
        C:\PS>.\UpdateTracking -NameLike Mexia -SetTracking True 
        This will update all BizTalk applications that have Mexia in their name and set their tracking to enabled.

    .NOTES
        Author: Matt Corr (Mexia) and Sandro Pereira (Devscope)
        Date:  18 November, 2014
    #>

    param( 
        [string]$NameLike = "", 
        [ValidateSet("True", "False")]
        [string] $SetTracking = "True")

    ######################################################################################################### 

    Function DetermineSendPortTracking($sp)
    {
        if ($SetTracking -eq "False")
        {
            return New-Object Microsoft.BizTalk.ExplorerOM.TrackingTypes
        }
        if ($sp.IsTwoWay)
        {
            return [Microsoft.BizTalk.ExplorerOM.TrackingTypes]::BeforeSendPipeline -bor 
                   [Microsoft.BizTalk.ExplorerOM.TrackingTypes]::AfterSendPipeline -bor
                   [Microsoft.BizTalk.ExplorerOM.TrackingTypes]::TrackPropertiesBeforeSendPipeline -bor
                   [Microsoft.BizTalk.ExplorerOM.TrackingTypes]::TrackPropertiesAfterSendPipeline -bor
                   [Microsoft.BizTalk.ExplorerOM.TrackingTypes]::BeforeReceivePipeline -bor 
                   [Microsoft.BizTalk.ExplorerOM.TrackingTypes]::AfterReceivePipeline -bor
                   [Microsoft.BizTalk.ExplorerOM.TrackingTypes]::TrackPropertiesBeforeReceivePipeline -bor
                   [Microsoft.BizTalk.ExplorerOM.TrackingTypes]::TrackPropertiesAfterReceivePipeline
        }
        else
        {
            return [Microsoft.BizTalk.ExplorerOM.TrackingTypes]::BeforeSendPipeline -bor 
                   [Microsoft.BizTalk.ExplorerOM.TrackingTypes]::AfterSendPipeline -bor
                   [Microsoft.BizTalk.ExplorerOM.TrackingTypes]::TrackPropertiesBeforeSendPipeline -bor
                   [Microsoft.BizTalk.ExplorerOM.TrackingTypes]::TrackPropertiesAfterSendPipeline
        }
    }

    ######################################################################################################### 

    Function DetermineReceivePortTracking($rp)
    {
        if ($SetTracking -eq "False")
        {
            return New-Object Microsoft.BizTalk.ExplorerOM.TrackingTypes
        }
        if ($rp.IsTwoWay)
        {
            return [Microsoft.BizTalk.ExplorerOM.TrackingTypes]::BeforeSendPipeline -bor 
                   [Microsoft.BizTalk.ExplorerOM.TrackingTypes]::AfterSendPipeline -bor
                   [Microsoft.BizTalk.ExplorerOM.TrackingTypes]::TrackPropertiesBeforeSendPipeline -bor
                   [Microsoft.BizTalk.ExplorerOM.TrackingTypes]::TrackPropertiesAfterSendPipeline -bor
                   [Microsoft.BizTalk.ExplorerOM.TrackingTypes]::BeforeReceivePipeline -bor 
                   [Microsoft.BizTalk.ExplorerOM.TrackingTypes]::AfterReceivePipeline -bor
                   [Microsoft.BizTalk.ExplorerOM.TrackingTypes]::TrackPropertiesBeforeReceivePipeline -bor
                   [Microsoft.BizTalk.ExplorerOM.TrackingTypes]::TrackPropertiesAfterReceivePipeline
        }
        else
        {
            return [Microsoft.BizTalk.ExplorerOM.TrackingTypes]::BeforeReceivePipeline -bor 
                   [Microsoft.BizTalk.ExplorerOM.TrackingTypes]::AfterReceivePipeline -bor
                   [Microsoft.BizTalk.ExplorerOM.TrackingTypes]::TrackPropertiesBeforeReceivePipeline -bor
                   [Microsoft.BizTalk.ExplorerOM.TrackingTypes]::TrackPropertiesAfterReceivePipeline
        }
    }

    ######################################################################################################### 
    # SQL Settings
    ######################################################################################################### 
    $BTSSQLInstance = get-wmiobject MSBTS_GroupSetting -namespace root\MicrosoftBizTalkServer | select-object -expand MgmtDbServerName
    $BizTalkManagementDb = get-wmiobject MSBTS_GroupSetting -namespace root\MicrosoftBizTalkServer | select-object -expand MgmtDbName

    ######################################################################################################### 
    # Connect the BizTalk Management database
    ###################################################################################################### 
    [void] [System.reflection.Assembly]::LoadWithPartialName("Microsoft.BizTalk.ExplorerOM")
    $BTSCatalog = New-Object Microsoft.BizTalk.ExplorerOM.BtsCatalogExplorer
    $BTSCatalog.ConnectionString = "SERVER=$BTSSQLInstance;DATABASE=$BizTalkManagementDb;Integrated Security=SSPI"

    ######################################################################################################### 
    # Get the BizTalk applications that match the nameLike param (or all if not specified)
    ######################################################################################################### 
    $BTSApplications = $BTSCatalog.Applications | Where-Object { $_.name -like "*$NameLike*"}

    if ($SetTracking -eq "False")
    {
        $OrchestrationTracking = [Microsoft.BizTalk.ExplorerOM.OrchestrationTrackingTypes]::None
        $PipelineTracking = [Microsoft.BizTalk.ExplorerOM.PipelineTrackingTypes]::None
        $SchemaTracking = $false
        $mode = "Disabling"
    }
    else
    {
        $OrchestrationTracking = [Microsoft.BizTalk.ExplorerOM.OrchestrationTrackingTypes]::OrchestrationEvents -bor
                                 [Microsoft.BizTalk.ExplorerOM.OrchestrationTrackingTypes]::InboundMessageBody -bor
                                 [Microsoft.BizTalk.ExplorerOM.OrchestrationTrackingTypes]::MessageSendReceive -bor
                                 [Microsoft.BizTalk.ExplorerOM.OrchestrationTrackingTypes]::OutboundMessageBody -bor
                                 [Microsoft.BizTalk.ExplorerOM.OrchestrationTrackingTypes]::ServiceStartEnd -bor
                                 [Microsoft.BizTalk.ExplorerOM.OrchestrationTrackingTypes]::TrackPropertiesForIncomingMessages -bor
                                 [Microsoft.BizTalk.ExplorerOM.OrchestrationTrackingTypes]::TrackPropertiesForOutgoingMessages

        $PipelineTracking = [Microsoft.BizTalk.ExplorerOM.PipelineTrackingTypes]::InboundMessageBody -bor
                            [Microsoft.BizTalk.ExplorerOM.PipelineTrackingTypes]::OutboundMessageBody -bor
                            [Microsoft.BizTalk.ExplorerOM.PipelineTrackingTypes]::MessageSendReceive -bor
                            [Microsoft.BizTalk.ExplorerOM.PipelineTrackingTypes]::ServiceStartEnd
        $SchemaTracking = $true
        $mode = "Enabling"
    }

    ######################################################################################################### 
    # Set tracking setting for all artifacts inside selected BizTalk Applications
    ######################################################################################################### 
    foreach ($Application in $BTSApplications)
    {
        $appName = $Application.name

        Write-host "$mode tracking for application: $appName" -ForegroundColor Cyan
        # Disable tracking settings in orchestrations    
           $Application.orchestrations | %{ $_.Tracking = $OrchestrationTracking }

           # Set tracking settings in Send and Receive ports       
        $Application.SendPorts | %{ $_.Tracking    = DetermineSendPortTracking($_) } 
           $Application.ReceivePorts | %{ $_.Tracking = DetermineReceivePortTracking($_) }

        # Set tracking settings in pipelines        
           $Application.Pipelines | %{ $_.Tracking = $PipelineTracking }

           # Set tracking settings in Schemas
           $Application.schemas |     ?{ $_ -ne $null } |  ?{ $_.type -eq "document" } | %{ $_.AlwaysTrackAllProperties = $SchemaTracking }
    }
    # Save tracking settings changes
    $BTSCatalog.SaveChanges()
    Write-host "Finished $mode trackings settings for selected applications." -ForegroundColor Green

Restart Host cmd script

After deploying BizTalk solutions it is best to recycle the host instances. Normally these are recycled serial. This script will recycle them in parallel by executing them in separate cmd’s.

start net stop btssvc$biztalkserverapplication 
start net stop BTSSvc$BizTalkServerApplicationBulk 
start net stop BTSSvc$BizTalkServerMSMQ 
start net stop BTSSvc$BiztalkServerReceive
start net stop BTSSvc$BizTalkServerReceiveBulk 
start net stop BTSSvc$BizTalkServerReceiveSingleServer
start net stop BTSSvc$BizTalkServerSend
start net stop BTSSvc$BizTalkServerSend32
start net stop BTSSvc$BizTalkServerSendBulk
start net stop BTSSvc$BizTalkServerSendSingleServer
start net stop BTSSvc$BizTalkServerTracking 

timeout /t 10

start net start btssvc$biztalkserverapplication 
start net start BTSSvc$BizTalkServerApplicationBulk 
start net start BTSSvc$BizTalkServerMSMQ 
start net start BTSSvc$BiztalkServerReceive
start net start BTSSvc$BizTalkServerReceiveBulk 
start net start BTSSvc$BizTalkServerReceiveSingleServer
start net start BTSSvc$BizTalkServerSend
start net start BTSSvc$BizTalkServerSend32
start net start BTSSvc$BizTalkServerSendBulk
start net start BTSSvc$BizTalkServerSendSingleServer
start net start BTSSvc$BizTalkServerTracking

Check the naming of the services en restart!

« Older posts

© 2019 venneker.net

Theme by Anders NorénUp ↑