3

I would like to change the vmsize of a running Azure web role during deployment preferrably using powershell.

Is this at all possible?

The use case here is that not all of our customers (and test environments) should run the same vm sizes, but they all use the same .csdef file.

3 Answers3

2

You can use the Set-AzureDeployment cmdlet to upgrade a webrole size, which you could then work into your existing PowerShell script. For instance, if you automatically deploy every customer web service/web role at a basic level/scale and then only upgraded them to larger capacity as needed, you could then use the following cmdlet as needed:

Set-AzureDeployment -Upgrade -ServiceName "MySvc1" -Mode Auto `
  -Package "C:\Temp\MyApp.cspkg" -Configuration "C:\Temp\MyServiceConfig.Cloud.csfg"

I would envision you just adding a parameter to your current PowerShell script, and if specified, run the above cmdlet to Upgrade the Azure Web role.

FoxDeploy
  • 12,569
  • 2
  • 33
  • 48
  • This still means I would have to change vmsize in my .csdef before building the .cspkg, right? I am trying to only have one .csdef and one .cscfg for all my deployments and then using only one release build in team city, use Octopus for the config replacements and other custom config stuff. I am thinking of modifying the .csdef before package build, but then I would need to know what vmsize to set which only Octopus really knows at this time. – Jonas Røineslien Apr 14 '15 at 07:25
  • No, you don't need to know the VM size, because you can just deploy small instances as your standard, and use this cmdlet to upgrade where needed. – FoxDeploy Apr 14 '15 at 11:40
  • 1
    If you mean manual update (using powershell) in the cases when I know I want a specific VM size, then yes I know I can do that, but as far as I can see running this script won't help me automate deployment of a web role with different vm sizes based on the environment. – Jonas Røineslien Apr 14 '15 at 11:49
1

This is not possible for a role, you have to do a new deployment with the settings change. You can however change the number of instances without redeploying maybe that could help you out?

On plain VM's you can use the following powershell snippet:

Get-AzureVM –ServiceName $ServiceName –Name $Name | 
Set-AzureVMSize $VMSize | 
Update-AzureVM

Taken from here

jakobandersen
  • 1,399
  • 7
  • 9
0

We use MSBuild to convert VM size in Service Definition file. It's part of the build step that runs before the deployment.

<Target Name="ChangeVM">
  <RegexReplace
    Pattern='vmsize="Standard_D3"'
    Replacement='vmsize="$(VMSize)"'
    Files='../Web/ServiceDefinition.csdef' />
</Target>

Where (VMSize) is the parameter coming from your build server.

stack247
  • 5,579
  • 4
  • 41
  • 64