2

Previously I have always had separate cloud projects for each environment, like this:

Cloud Project layout

This poses some problems:

  • Maintaining multiple ServiceDefinition.csdef files
  • When building to a common output path, which ServiceDefinition.csdef is copied?

I am proposing using a single Cloud Project with multiple ServiceConfiguration files for each environment, and multiple profiles for publishing:

Single Cloud Project

Pros:

  • Less maintenance issues (1 project and 1 ServiceDefinition.csdef)
  • A single ServiceDefinition.csdef is copied to the output folder

The problem I have now is that all environments need to have the same instance size as this is defined in the ServiceDefinition.csdef.

Is there any way I can get around this problem?

Dave New
  • 38,496
  • 59
  • 215
  • 394
  • Consider using powershell for deployment (build the package with cspack). Then you can patch the definitions for each specific environment before you build the package. – Martin Brandl Jun 11 '14 at 13:20
  • Our build server is currently creating a package from the ServiceDefinition. Do you create multiple packages? One for each environment? How do you patch the definition before creating the package? – Dave New Jun 11 '14 at 13:53

1 Answers1

1

Yes, we create multiple packages (one for each environment). We have different powershell scripts to patch things like the vm-size (one example):

param(
    [parameter(Mandatory=$true)]
    [string]$fileToPatch,

    [parameter(Mandatory=$true)]
    [string]$roleName,

    [parameter(Mandatory=$true)]
    [validateSet("ExtraSmall", "Small", "Medium", "Large", "ExtraLarge", "A5", "A6", "A7")]
    [string]$vmsize = 'Small'
)
#  MAIN

$xml = New-Object System.Xml.XmlDocument
$xml.Load($fileToPatch)

$namespaceMgr = New-Object System.Xml.XmlNamespaceManager $xml.NameTable
$namespace = $xml.DocumentElement.NamespaceURI
$namespaceMgr.AddNamespace("ns", $namespace)

$xpathWorkerRoles = "/ns:ServiceDefinition/ns:WorkerRole"
$xpathWebRoles = "/ns:ServiceDefinition/ns:WebRole"
$Roles = $xml.SelectNodes($xpathWebRoles, $namespaceMgr) + $xml.SelectNodes($xpathWorkerRoles, $namespaceMgr)

$Roles | Where-Object { $_.name -eq $RoleName} | % { $_.vmsize = $vmsize; Write-Host 'Patched vmsize to' $vmsize 'for' $_.name } 

$xml.Save($fileToPatch)
Martin Brandl
  • 56,134
  • 13
  • 133
  • 172