Geeks With Blogs

News This is the *old* blog. The new one is at blog.sixeyed.com
Elton Stoneman
This is the *old* blog. The new one is at blog.sixeyed.com

[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.

Posted on Wednesday, December 10, 2008 11:09 PM BizTalk 2006 R2 , PowerShell scripts , MSBuild , BizTalk 2009 | Back to top


Comments on this post: BizTalk Deployments with PowerShell

# re: BizTalk Deployments with PowerShell
Requesting Gravatar...
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.
Left by Glen on Aug 21, 2009 1:44 PM

# re: BizTalk Deployments with PowerShell
Requesting Gravatar...
Hi, thanks for sharing the install script!
Left by Drain Clearance on May 12, 2010 2:35 PM

# re: BizTalk Deployments with PowerShell
Requesting Gravatar...
This is a little beyond me compared to some of the scripts recently. Thanks though.
Left by Forex Trading Systems on Dec 22, 2010 2:25 PM

# re: BizTalk Deployments with PowerShell
Requesting Gravatar...
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.
Left by phone sales training on Feb 02, 2011 8:41 AM

# re: BizTalk Deployments with PowerShell
Requesting Gravatar...
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....
Left by Post Advertisements for Free on Mar 16, 2011 5:57 AM

# re: BizTalk Deployments with PowerShell
Requesting Gravatar...
Thanks to Patterns & Practices team. They have simplified my task in assuring the workability of this system.
Left by online graduate degrees on May 13, 2011 8:07 AM

# re: BizTalk Deployments with PowerShell
Requesting Gravatar...
Great read and good luck ;-)
Indian escorts London
Left by London Escorts on Jun 05, 2011 12:04 AM

# re: BizTalk Deployments with PowerShell
Requesting Gravatar...
Did u a change to download and test drive

http://biztalkcontrolcenter.codeplex.com
Left by Naveen on Jul 13, 2011 4:53 PM

# re: BizTalk Deployments with PowerShell
Requesting Gravatar...
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
Left by North Face Jackets For men on Nov 19, 2011 7:52 AM

# re: BizTalk Deployments with PowerShell
Requesting Gravatar...
Elton, we are seriously looking into some of the better deployment options. It's shame Microsoft didn't provide out of the box PowerShell provider for BizTalk. We are using custom built MSBuild Scripts with SDC tasks library (http://sdctasks.codeplex.com/) at the moment. We are also looking into couple of commercial deployment tools. I hope there will be official powershell provider for BizTalk in 2010 R2 or 2013 (whatever it's going to be called)
Left by Saravana Kumar on Apr 26, 2012 12:40 PM

# re: BizTalk Deployments with PowerShell
Requesting Gravatar...
Reading forex brokers handbooks on the web is exhaustive. I was thankful to feel invigorated in checking out this blog.
Left by Joy Caldwell on May 08, 2014 2:52 AM

# re: BizTalk Deployments with PowerShell
Requesting Gravatar...
This is interesting. Thanks for sharing. Where might I find the source code for this example?
Left by Everett on Nov 19, 2014 10:17 PM

Your comment:
 (will show your gravatar)


Copyright © Elton Stoneman | Powered by: GeeksWithBlogs.net