venneker.net

.NET, BIZTALK, ESB, AZURE

Category: BizTalk (page 1 of 17)

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!

Starting all EDI batches

When you are using the EDI batching functionality for outgoing messages in the BizTalk platform, it can be an effort to start all the batching for an environment.

The batching is located in the BizTalk EDI Application:

This is included with the BizTalk server installation as an extra option. The application consist of 4 orchestrations and receive and send locations:

With this you need to configure the batching on the agreement in the party configuration. Here are a few links how to do just that:

Batching Outgoing EDI Messages
BizTalk 2010 EDI Batching Tutorial
All you need to know about Outbound EDI Batching

The only thing is that you have to start every batching from the EDI agreement party configuration. And that can be frustrating…. Especially when you have some 20 batches to be started for a release. So I created a script to do just this. Start all batching for all agreements that have batching. And here it is:


DECLARE @BatchIdNew BigInt,
@BatchName nvarchar (256),
@ReceiverPartyName nvarchar (256),
@SenderPartyName nvarchar (256),
@AgreementName nvarchar (256);

DECLARE c CURSOR FOR
SELECT Id, Name,
(SELECT [Name] FROM [tpm].[Partner] WHERE [PartnerId]=(SELECT [PartnerId] FROM [tpm].[BusinessProfile] WHERE [ProfileId]=(SELECT [ProfileId] FROM [tpm].[BusinessIdentity] WHERE Id=(SELECT [ReceiverId] FROM [tpm].[OnewayAgreement] WHERE Id=BatchDescription.[OnewayAgreementId])))) AS ReceiverName,
(SELECT [Name] FROM [tpm].[Partner] WHERE [PartnerId]=(SELECT [PartnerId] FROM [tpm].[BusinessProfile] WHERE [ProfileId]=(SELECT [ProfileId] FROM [tpm].[BusinessIdentity] WHERE Id=(SELECT [SenderId] FROM [tpm].[OnewayAgreement] WHERE Id=BatchDescription.[OnewayAgreementId])))) AS SenderName,
(SELECT [Name] FROM [tpm].[Agreement] WHERE [SenderOnewayAgreementId]=BatchDescription.[OnewayAgreementId]) AS AgreementName
FROM [BizTalkMgmtDb].[tpm].BatchDescription
OPEN c;
FETCH NEXT FROM c into @BatchIdNew, @BatchName, @ReceiverPartyName, @SenderPartyName, @AgreementName;

WHILE @@FETCH_STATUS = 0
BEGIN

EXEC [BizTalkMgmtDb].dbo.edi_CreateControlMessage_Activate @BatchId=@BatchIdNew,@EdiMessageType=1,
@BatchName=@BatchName,@ReceiverPartyName=@ReceiverPartyName,@SenderPartyName=@SenderPartyName,@AgreementName=@AgreementName
FETCH NEXT FROM c into @BatchIdNew, @BatchName, @ReceiverPartyName, @SenderPartyName, @AgreementName;

END

You will run this on the management database of BizTalk, and all your batching will be started. Good luck!

Batch Id xxx not found. Check if batch and party exist. (Microsoft.BizTalk.Edi.Shared)

I had this error when starting a batch from an agreement from the BizTalk admin console. (Batching of outgoing EDI messages is supported in BizTalk.  Here is a good example how to use the BizTalk batching) There were 2 things you can try for this.

  • Let the SQL sysadmin try to start the batches
  • Try to import the parties again.

Very strange but when the parties were imported again, I could start the batching.

 

This is the complete error:


TITLE: BizTalk Server Administration
------------------------------

Exception has been thrown by the target of an invocation. (Microsoft.ManagementConsole)

------------------------------
ADDITIONAL INFORMATION:

Batch Id 27 not found. Check if batch and party exist. (Microsoft.BizTalk.Edi.Shared)
« Older posts

© 2019 venneker.net

Theme by Anders NorénUp ↑