Sunday, 16 November 2014

Demo Release Template for VS 2013 Release Management – Part 2

In this second part of Demo Release Template in Visual Studio Release Management, I will explain how to define a simple deployment sequence to create an IIS application pool and a website.

We can add a Server, or Tag to the deployment sequence. Using a Tag is better since it will allow copy and pasting the template to different stages of the pipeline and even if the servers (will be different servers always in real life) are different in each stage, the tag locates the server related to the correct environment.

001

Let’s add WebSvr (Tags defined when we setup the Servers & Environments) to the deployment sequence in our DevInt stage.

002

The first action we are going to add to the deployment sequence of the web server is create the app pool action. More details of default available release actions can be found in MSDN - Release actions to deploy an app for Release Management.

003

Let’s set parameters to create the application pool, .Net framework and the app pool name.

004

005

Next action we are adding is create website.

006

Let’s set App Pool, Site Name, Port etc. for website.

007

We need to create a deployment component to copy the TFS build output to our web site folder (Build definition for the template was defined in Part1)

008

Click New to create new component.

009

Give a name to the component and select Builds with application. There are different options you can select as you can see below.

010

Release Management server will locate the build drop of the referred TFS build in template. we have to specify our website content location. If it is in the root of the build drop we can specify \ character.

011

012

In the Deployment tab of the component select XCopy Deployer and click Save & Close.

012.1 

Select the new component created and click Link.

013

Now the component is available in our release template.

014

Add the component to the deployment sequence and set the installation path parameter to the Web Site physical file folder.

015

 016

Now we can copy the WebSvr sequence to the next stage (QA).

017

018

019

 

Change the parameters of actions for the QA stage.

020

 021

022

We can do same for the Prod.

023

024

025

Save and Close the release template.

Next go to Release tab of the Release Management Client and click New.

026

Select the Target Stage as Prod so that our release will deploy through the pipeline from DevInt—>QA—>Prod.

027

Click on Latest to select the latest successful build.

028

Click on Create in Draft.

029

We can compare and verify configuration variables before we start the release.

030

 031

 033

Start the release and since all stages set up to deploy automatically, release will deploy from DevInt—>QA—>Prod.

034

 035

 036

We can see the three application pools getting created (in same server since we use a single server for  all the stages in this demo).

037

Three websites created as well.

038

XCopy Deployer component has copied web site files to the Web Site physical folders.

039

The web sites are up and running.

042

With this Visual Studio Release Management series of posts I have explained how to setup Release Management Server, Client etc., configure and do a simple deployment. VS Release Management has lot more features and could be used to do lot more complex deployments. It has advanced security management options to setup groups, control permissions for each stage, template etc.

Thursday, 23 October 2014

Demo Release Template for VS 2013 Release Management – Part 1

Release Template defines how the deployment happens in the Release Path in VS 2013 Release Management. Downloading build output to deployment machine, installation of various software components in different machines in the environment, setting up configurations, parameters etc., rollback deployment on failure are few of the actions executed as defined in a release template. Different deployment sequence can be defined for each stage of the release path.
To define a release template Click New on Configure Apps tab of the VS Release Management Client.
001
Provide a name for the release template
002
Select the Release Path
003
Since the TFS is integrated with the release management server, we can select a build definition that can be used to obtain the deployment package/payload.
Select the Team Project
004
Then select the build definition which is generating output.
005
The  purpose of “Can Trigger a Release from a Build” is to allow triggering a Release from the TFS build. But this requires some additional steps in Build templates and definitions which I will explain in a future post.
Security tab can be used to configure following permissions for Release Management users or groups.
006
View – Can view this Release Template
Edit – Can edit this Release Template
Can Release – Can trigger a release using this Release Template
Manage Security – Can edit permissions for this Release Template
Click on Create to save the release template
007
The above shown window can be opened by clicking the properties link below and edit the properties of release template after creation.
008
Since our release path had three stages DevInt, QA and Prod we can define a deployment sequence for each of these stages.
009
You can see the tags we have defined in each environment appears in left toolbox under tags. Since we are using the same server machine for this demo there is only one and same server in each stage.
010
In the second part of this post, I will explain how to define a simple deployment sequence.

Wednesday, 8 October 2014

Setup Release Path in VS Release Management

Release path in VS Release Management defines the order of the stages of the release pipeline for a given software product/project. Release path can be used to configure in which order build output gets deployed to environment specified in each stage  (Dev Integration, QA, UAT, Production etc.) and who accepts approves each step in a controlled workflow.
Configuring release path is a prerequisite to set up a release template which controls the deployment to each environment in release pipeline stages.
001
Navigate to Configure Paths – > Release Path in Release Management Client.
002
Click New to create new release path and provide a name and a optional description.
003
Click Add on Stages tab to configure the first stage.
004
The first stage is going to be DevInt in this demo. Select the environment getting deployed in this stage. (Environment visible and allowed to select in each stage can be controlled using environment Stage Type Security).
005
Deployment to the stage can be set to approve manually or automatically. If manual notification email can be configured and will be sent to the Approver or Group, and the Approver can use Release Management Client or Web Application link in email to visualize the release progress and approve/reject it (Approve to be deployed in later date and time is also possible).
Deployment step execution will be notified to the owner if configured. Validator can validate the deployment and approve/reject deployment to be tested by the stage approvers. When the stage approvers approve the stage deployment will flow to the next stage in the release path.
006 
Similarly can be setup for QA and Production stages, and for the demo everything is set to automated. Since ) Approvers for each stage below deployment will run next stage in release path if succeeds in the current stage.
007
Next step is to define a release template using the Release Path.
008

Saturday, 27 September 2014

Setup Servers & Environments for VS 2013 Release Management

Another prerequisite to getting VS Release Management to automate release workflow is setting up the Servers & Environments. To register as a Server in VS Release Management, machine should be first installed with Microsoft Deployment Agent.
001
Note - The above view in Configure Apps only available until all mandatory steps are done only. It disappears after all mandatory configurations are once done. Items shown in above can be accessed in different tabs and section in the release management client.
1. Registering Server
In VS Release Management Client click on Configure Apps –> Add Servers link or Click on Configure Paths –> Servers
002
Click on New –> Scan For New to find available Deployment Agent installed and configured machines.
003
Optionally enter a prefix or suffix and Click on Register button to register the server found.
004
 005
Machine get registered as a server and initially shown as offline.
006
Once the heartbeat is received from deployment agent to release management server, machine shows as ready.
007
Next step is creating environments, with successfully registered servers.
008
2. Setup environment
Click on Environments link in Configure Apps  or in Configure Paths click on Environments.
009
Click on New to create new environment.
010
Provide a Name and click on Link Existing to link registered servers to the environment.
011
Select the available server(s) and click Link.
012
You can add tags. These tags are useful when setting up release templates. The tag can be used instead of Server name which allows copying templates workflow steps easily between different stages in the release template.
First environment is created as DevInt (Dev. Integration)
013
Stage Type Security can be used to restrict the stages in release path that the environment can be used.
013_1
For demo purpose QA and Production environments set up with same Server. In practical scenario these will be different servers. and environment may contain multiple servers linked.
QA
014
Production
015
Servers and Environments configuration is successfully completed.
 016
017

Tuesday, 16 September 2014

Using TFS Work Items - Part 2 & TFS Builds

This is the second part of the TFS Work Items session by me @ MSFT Sri Lanka. First session is available here.


Monday, 8 September 2014

Tool to Execute Multiple SQL Scripts – VS 2013 Release Management – Part 1

Is it possible to execute set of SQL scripts downloaded to Deployment Agent in VS 2013 Release Management? Yes. But this requires a custom tool and an action.
Let’s see how we can do this step by step.
As the first step write a PowerShell script capable of executing batch of scripts in a transaction.
 Param([string]$ServerInstance, [string]$DatabaseName, [string]$ScriptPath)   
  $ErrorOccured = $false   
  #Executing following snapins to Invoke-SqlCmd    
  Add-PSSnapin SqlServerCmdletSnapin100 -ErrorAction SilentlyContinue   
  Add-PSSnapin SqlServerProviderSnapin100 -ErrorAction SilentlyContinue   
  Write-Host "Executing patch scripts of path: $PatchScriptsPath"   
  Start-Transaction -RollbackPreference Error   
  Use-Transaction -TransactedScript {    
   foreach ($file in Get-ChildItem -path $ScriptPath -Filter "*.sql")   
   {    
    Write-Host Executing: $file.name ...   
    $ScriptPath = $ScriptPath + "\" + $file.name   
    Invoke-Sqlcmd -ServerInstance $ServerInstance -Database $DatabaseName -InputFile $ScriptPath -ErrorAction SilentlyContinue -ErrorVariable errors   
    foreach($error in $errors)   
    {   
     if ($error.Exception -ne $null)   
     {   
      $ErrorOccured = $true   
      Write-Host -ForegroundColor Red "Exception: $($error.Exception)"   
     }   
    }   
   }   
  } -UseTransaction    
  if ($ErrorOccured)   
  {   
   Undo-Transaction   
   throw "Error occured while Executing SQL Scripts."   
  }   
  else   
  {   
   Complete-Transaction   
   Write-Host Successfully executed all SQL scripts.   
  }  

Next create a tool in Release Management Client as shown below.

a1

Parameters are

NameTypeDescription
ServerInstanceStandardSQL Server Name with Instance Name
DatabaseNameStandardName of the database the scripts should run
ScriptPathStandardLocation of the scripts to be executed


Create an action as shown below using the tool created above.

a2

This action can be used in a release template as shown below to execute SQL scripts in a transaction.

a3



On failure scripts actions will not be committed and release management action will fail. In Part 2, I will show this tool in action.

Wednesday, 3 September 2014

Setup Stage Types in VS Release Management

Stage Types are used in VS Release Management to define stages that are going to be utilized in Release path. In other words stage types are the release will transition through. This is one of mandatory configuration settings in VS Release Management.
001
Click on Stage Types link as shown in above picture, in Release Management Client (This is available only when initial configurations are not complete) or in the Administration tab –> Manage Pick Lists to configure Stage Types.
002 
It is possible to add stages such as DevInt, QA, UAT, Production etc as shown below.
003
Another pick list that can be added is, Technology Types, which is used to categorize the applications by technology stack when defining Servers and Environments. This is optional configuration in VS Release Management.
004
Technology Type such as SQL, Web etc. can be added.
005
Once added above Configure Apps tab shows summary of configured items.
006

Popular Posts