Using rolling deployment with an Azure Load Balancer

Hi,
I’m trying to figure out a way to use the Rolling Deployment feature to deploy a web site to two Azure Virtual Machines (Web1 and Web2) behind an Azure Load Balancer. I have created a Rolling Deployment step with a Window Size of 1. I want to have zero downtime of the web site.

At the moment, the best way I can think of is to have a Manual Intervention step:

  • for first iteration in the Rolling Deploy, the operator would remove Web1 from Load Balancer & Octopus would deploy to Web1.
  • the second iteration in Rolling Deploy, operator would put Web1 back online, remove Web2 and deploy to Web2
    Last step is to bring Web2 back online.

Would you say this is best practice, or would it be better to have steps in the Deployment (eg Powershell) to remove/add VMs from Load Balancer? If so can you point me to resource with example?

Cheers
Joe

Hi Joe,

Thanks for getting in touch! It looks like you have the right idea here. While the Manual Intervention step will work, the best automated method for doing this is to create script steps to manage removing from the load balancer and then placing it back at the end. The following documentation page on our rolling deployments has a little bit more information on this.

However, the idea is pretty much as you pointed out. Have a script step with PowerShell that manages the load balancing, which will remove the need for a manual intervention and manual management of the load balancer.

Let me know if you have any further questions here or are hitting any road blocks. :slight_smile:

Best regards,
Daniel

Hi Daniel,

I configured my deployment process with two Azure Powershell steps – one to take the current target out of the load balancer, then one to add the target back in to the load balancer.

This is the script I’m using to take the current target out of the load balancer:

$octoMachine = $OctopusParameters[‘Octopus.Machine.Name’]

$rgName = ‘SandboxTest’
$nicName = ‘nic1’

If ( $octoMachine -eq “Sandbox1” ) {
Write-Output “About to take Sandbox1 out of Load balancer back end pool”
$nicName = ‘nic1’
}
If ( $octoMachine -eq “Sandbox2” ){
Write-Output “About to take Sandbox2 out of Load balancer back end pool”
$nicName = ‘nic2’
}
$nic = Get-AzureRmNetworkInterface -ResourceGroupName $rgName -Name $nicName
$nic.IpConfigurations[0].LoadBalancerBackendAddressPools = $null
Set-AzureRmNetworkInterface -NetworkInterface $nic
Write-Output “Done - removed from backend pool”

This is working fine but feels a bit “hacky” with that IF statement and the hardcoded target names.

Is there a better way to do this?

Cheers
Joe

Hi Joe,

Thanks for getting back. Sorry for the delay in responding to you. We didn’t really see a better way to do this than your solution. Not while the nickname is different to the Octopus machine name.
One possible idea could be to append the nickname to the machine name. E.g: Sandbox1_nic1, then split by _.

Let me know if you have any questions here?

Best regards,
Daniel