Elton Stoneman

  Home  |   Contact  |   Syndication    |   Login
  120 Posts | 0 Stories | 3607 Comments | 0 Trackbacks

News

Archives

Post Categories

[Source: http://geekswithblogs.net/EltonStoneman]

As part of my first look at ESB Guidance 2.0 (which has some excellent enhancements which I'll post about shortly) I've been interested in the way the sample solutions are deployed. The P&P team have put together PowerShell scripts which take care of the usual things you'd find in a deployment scenario – stopping services, creating applications, adding resources and bindings.

In a Continuous Integration environment, you'd typically want to deploy to a BizTalk instance as part of the build process, to ensure the application configuration is valid, and as a prerequisite for running unit and integration tests. Currently I do this with MSBuild scripts using a variety of community, Sdc and custom tasks, and command-line tools. It makes for fragmented scripts that are difficult to read and maintain, and can be fragile to execute.

In the PowerShell version a central script isolates the complexity for common functions, and then the individual install scripts use a neat, readable and hugely intuitive syntax. This is a complete install script for one of the sample solutions (MultipleWebServices_install.ps1), which builds and then deploys the artifacts:

$relativePath = "..\.."

$samplesPath = $solutionPath+"\Samples\MultipleWebServices"

. ..\..\..\..\Core\Install\Scripts\ESBFunctions.ps1

 

function BuildItinerarySolution

{

 

    param([System.String] $buildType)

 

    &$FrameworkPath"\v3.5\MSBuild.exe" $relativePath"\GlobalBank.ESB.Samples.MultipleWebServices.sln" /t:Rebuild /p:Configuration=$buildType

}

 

BuildItinerarySolution Debug

StopBTSApplication "Microsoft.Practices.ESB"

StopBTSApplication "GlobalBank.ESB"

StopBTSServices

 

ImportBTSResource "GlobalBank.ESB" "BizTalkAssembly" $relativePath"\Source\ESB.MultipleWebServices.Maps\bin\Debug\ESB.MultipleWebServices.Maps.dll"

ImportBTSResource "GlobalBank.ESB" "BizTalkAssembly" $relativePath"\Source\ESB.MultipleWebServices.Orchestrations\bin\Debug\ESB.MultipleWebServices.Orchestrations.dll"

GacOperation "-if" $relativePath"\Source\ESB.MultipleWebServices.Maps\bin\Debug\ESB.MultipleWebServices.Maps.dll"

GacOperation "-if" $relativePath"\Source\ESB.MultipleWebServices.Orchestrations\bin\Debug\ESB.MultipleWebServices.Orchestrations.dll"

 

ImportBinding "GlobalBank.ESB" $relativePath\Install\Binding\GlobalBank.ESB.MultipleWebServices_Bindings.xml

 

StartBTSApplication "Microsoft.Practices.ESB"

StartBTSApplication "GlobalBank.ESB"

 

StartBTSServices

The common script (ESBFunctions.ps1) defines the main functions – ImportBTSResource etc. – so the logic in the individual scripts is very clean. Common functions make use of PowerShell commands, the BizTalk Explorer OM, BTSTask and custom tools as appropriate, so there's still a variety of tools under the covers, but the common script is a facade over them all. This makes the install scripts neater and abstracts them from the actual implementation of the functions. Below are snippets for the functions to stop and to remove a BizTalk application:

function StopBTSApplication

{

    param([string]$appName)

 

    $exp = New-Object Microsoft.BizTalk.ExplorerOM.BtsCatalogExplorer

    $exp.ConnectionString = $btsConnectionString

    $app = $exp.Applications[$appName]

    if($app -eq $null)

    {

        Write-Host "Application " $appName " not found" -fore Red

    }

    else

    {

        if($app.Status -ne 2)

        {

            #full stop of application

            $null = $app.Stop(63)

            $null = $exp.SaveChanges()

            Write-Host "Stopped application: " $appName

        }

    }

 

}

 

function RemoveBTSApplication

{

    param([string]$appName)

 

    Write-Output "Removing BTS Application "+ $appName

    BTSTask.exe RemoveApp /A:$appName

}

There's some complexity in these common functions, but they're all tried and tested by the Patterns & Practices team. This is a new approach for the ESB Guidance installs (v1.0 used a combination of batch files to deploy the samples), but I don't think there are any inherent dependencies on BTS 2009 so this approach and the common script should work for BTS 2006 solutions. I'm going to look at migrating my current build scripts to this approach as it's so much simpler to work with, and the execution doesn't rely on chaining together unrelated tasks in MSBuild.

The ESBG samples specifically name resources to deploy, whereas my current scripts run dynamically over whichever artifacts they find, but Bart De Smet has a nice MSBuild task for running PowerShell scripts, which takes parameters so that's one option, and generating PS scripts using the ExecuteT4Template task is another.

If I do get this running for BizTalk 2006 R2 solutions, I'll post a working set of sample scripts.

  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati
posted on Wednesday, December 10, 2008 11:09 PM

Feedback

# re: BizTalk Deployments with PowerShell 8/21/2009 1:44 PM Glen
Did you ever get this working with BT 2006 R2? My group will hopefully someday upgrade BT, but meanwhile I'm hoping I can borrow the deployment process.

# re: BizTalk Deployments with PowerShell 5/12/2010 2:35 PM Drain Clearance
Hi, thanks for sharing the install script!

# re: BizTalk Deployments with PowerShell 12/22/2010 2:25 PM Forex Trading Systems
This is a little beyond me compared to some of the scripts recently. Thanks though.

# re: BizTalk Deployments with PowerShell 2/2/2011 8:41 AM phone sales training
A sample BizTalk application that uses PowerShell in its post-processing script for advanced deployment functionality: modifying the BizTalk config file, making receive locations, making a happening phones sales Log Application sink, and adding SSO application to store configuration. this can be additionally utilized in one amongst sales coaching techniques that i have been last summer.

# re: BizTalk Deployments with PowerShell 3/16/2011 5:57 AM Post Advertisements for Free
Interesting topic. I wished I could read more, but i have to go back to work now... But I'll be back. Hope will come up with more....

# re: BizTalk Deployments with PowerShell 5/13/2011 8:07 AM online graduate degrees
Thanks to Patterns & Practices team. They have simplified my task in assuring the workability of this system.

# re: BizTalk Deployments with PowerShell 6/5/2011 12:04 AM London Escorts
Great read and good luck ;-)
Indian escorts London

# re: BizTalk Deployments with PowerShell 7/13/2011 4:53 PM Naveen
Did u a change to download and test drive

http://biztalkcontrolcenter.codeplex.com

# re: BizTalk Deployments with PowerShell 11/19/2011 7:52 AM North Face Jackets For men
North Face Jackets, both North Face Jackets For Women and North Face Jackets For men, are playing an important role in our fall, winter and spring life. They can be your daily necessities. They can also be a great gift to your families or friends to show your love. An awesome North Face Jackets as a birthday, Thanks Given Day, Christmas Day or Valentine's Day gift would surely make the receiver full of gratitude and love towards you.3

Post A Comment
Title:
Name:
Email:
Website:
Comment:
Verification: