• Michael Intravartolo

Change vmsize for a azure cloud service in octopus deploy

A common case when running a test/staging and production environment using Azure Cloud Service is that you don't want to use the same vmsize for all environments. It can actually be very expensive. To solve this we need to-do some variable substitution in the azure cloud service package. Doing variable substitution on ServiceConfiguration.XXX.cscfg is done by default when using the built in template "Deploy an Azure Cloud Service" but it doesn't support variable substitution on ServiceDefinition.csde by default where the vmsize is defined. To accomplish this we need to create a pre-deployment PowerShell script.

  1. In your process step based on "Deploy an Azure Cloud Service" Click on enable features

  2. Check mark "Custom deployment scripts" and apply the change

  3. You can now add script for pre-deployment, deployment, and post-deployment.

  4. The last thing is to add the variable Deploy. WebApiRoleVMSize setting the vmsize you want for different scope or environments.

Add this script to the "Pre-deployment" section and replace "NNN" with the name of the webrole.

write-host "Starting Service Definition rewrite"

$def = "ServiceDefinition\ServiceDefinition.csdef"

$csdeffile = Get-Item $def [xml]$csdefcontent = get-content $csdeffile

#Find the webrole we want in a multi-webrole cloud service. Assume this exists $webrole = $csdefcontent.ServiceDefinition.WebRole | where {$_.name -eq "NNNN"}

##Update the vmsize. Add if not available $webrole.SetAttribute("vmsize",$OctopusParameters['Deploy.WebApiRoleVMSize']) write-host "Using VMSize '" $OctopusParameters['Deploy.WebApiRoleVMSize'] "' for NNNNN"

#Save the changes $csdefcontent.Save($csdeffile.FullName)

write-host "Service Definition rewrite successful"

Contact Us

Solution Systems, Inc.

3201 Tollview Dr. 

Rolling Meadows, IL 60008

Office: 847-590-3000

Email: info@solsyst.com

Support: 224-345-2020

Support Email: support@solsyst.com

Connect With Us
  • Manufacturing Software | Illinois
  • Manufacturing Software | Illinois
  • Manufacturing Software | Illinois
  • Manufacturing Software | Illinois
  • Manufacturing Software | Chicago
  • Manufacturing Software | Illinois
  • Microsoft Business Podcast
  • Manufacturing Software | Chicago
  • Manufacturing Software | Chicago
  • Manufacturing Software | Chicago
Join our Mailing List

© 2020 Solution Systems, Inc.