I'm struggling to get to grips with Reserved IP addresses in an Azure Cloud Service.
I have a Cloud Service with Staging and Productions deployments and I need at least the Production deployment to have a stable IP address. I set up 2 Reserved IP addresses as described here then assigned my reserved IPs to the Production and Staging deployments with Power Shell:
Set-AzureReservedIPAssociation -ReservedIPName MyReservedIP1 -ServiceName mycloudservice -Slot “Production”
Set-AzureReservedIPAssociation -ReservedIPName MyReservedIP2 -ServiceName mycloudservice -Slot “Staging”
All well and good the reserved IPs get assigned to the respective instances and swapping maintains the correct addresses. The problem is if I delete one of the deployments and redeploy the IP address is not maintained.
I also tried assigning a reserved IP address to the cloud service without specifying a "Slot" and it assigned fine but does not seem to get used in either Production or Staging deployments.
Set-AzureReservedIPAssociation -ReservedIPName MyReservedIP -ServiceName mycloudservice
My usual workflow would be to deploy to Staging then swap with Production once I have tested all is working fine. With this scenario how can I ensure the Production deployment always gets a Reserved IP address when I swap from Staging, even if there is no current Production instance deployed?
The Azure documentation says "IP address for the cloud service will be the same even as resources are shutdown or deallocated" so shouldn't my previously assigned Production IP address be maintained even if I delete the Production instance and then swap from Staging?
192.168. 1.1 : Reserved by Azure for the default gateway.
Per Microsoft: "Azure reserves 5 IP addresses within each subnet. These are x.x.x.0-x.x.x.3 and the last address of the subnet. x.x.x.1-x.x.x.3 is reserved in each subnet for Azure services.
When you use DHCP IP reservation, you're telling your Wi-Fi network to assign the same IP address to a specific device whenever that device connects to your network.
You can assign static internal IP addresses by deploying the NextGen Firewall F-Series via the new Azure portal, or by changing the IP address for existing VMs via Azure PowerShell. The Azure virtual machine will automatically reboot when assigning the static IP address.
This worked for me:
Create your reserved IPs
New-AzureReservedIP -ReservedIPName "ip1" -Location "East US 2"
New-AzureReservedIP -ReservedIPName "ip2" -Location "East US 2"
Deploy to the production slot with the following network configuration in your .cscfg file:
<NetworkConfiguration>
<AddressAssignments>
<ReservedIPs>
<ReservedIP name="ip1" />
</ReservedIPs>
</AddressAssignments>
</NetworkConfiguration>
Deploy to the staging slot with the following configuration:
<NetworkConfiguration>
<AddressAssignments>
<ReservedIPs>
<ReservedIP name="ip2" />
</ReservedIPs>
</AddressAssignments>
</NetworkConfiguration>
Continue using your normal workflow - deploy to staging, then swap to production. The IP addresses should stay associated with their slots (ip1 in production and ip2 in staging).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With