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.
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
Click on New –> Scan For New to find available Deployment Agent installed and configured machines.
Optionally enter a prefix or suffix and Click on Register button to register the server found.
Machine get registered as a server and initially shown as offline.
Once the heartbeat is received from deployment agent to release management server, machine shows as ready.
Next step is creating environments, with successfully registered servers.
2. Setup environment
Click on Environments link in Configure Apps  or in Configure Paths click on Environments.
Click on New to create new environment.
Provide a Name and click on Link Existing to link registered servers to the environment.
Select the available server(s) and click Link.
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)
Stage Type Security can be used to restrict the stages in release path that the environment can be used.
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.
Servers and Environments configuration is successfully completed.

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: $ ...   
    $ScriptPath = $ScriptPath + "\" + $   
    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)   
   throw "Error occured while Executing SQL Scripts."   
   Write-Host Successfully executed all SQL scripts.   

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


Parameters are

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.


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


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.
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.
It is possible to add stages such as DevInt, QA, UAT, Production etc as shown below.
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.
Technology Type such as SQL, Web etc. can be added.
Once added above Configure Apps tab shows summary of configured items.

Popular Posts