When deploying a cloud service, you will be assigned a random Public Virtual IP (VIP) address. This address will change if you delete your Web/Worker role and then deploy another version of your code.
With the latest release of the Azure PowerShell Cmdlets, you can now reserve the VIP address that was assigned to your Web/Worker role by using the following cmdlet.
New-AzureReservedIP –ReservedIPName <name of reservation> –Location <region> –ServiceName <name of your service>
eg: New-AzureReservedIP –ReservedIPName “myIPReservation” –Location “Australia East” –ServiceName “myWorkerRoleName”
Check if the reservation has been successful by executing the following cmdlet: Get-AzureReservedIP. Note the InUse should be True and the ServiceName is the name of your Web/Worker role.
Now to ensure that your cloud service will always use the reserved IP address with each new deployment, you will need to update the Service Configuration Schema (CSCFG) and add the ReservedIP element.
1: <ServiceConfiguration serviceName="TCPSocketListener" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration" osFamily="4" osVersion="*" schemaVersion="2015-04.2.6">
2: <Role name="WorkerRole1">
3: <Instances count="1" />
4: <ConfigurationSettings>
5: </ConfigurationSettings>
6: </Role>
7: <NetworkConfiguration>
8: <AddressAssignments>
9: <ReservedIPs>
10: <ReservedIP name="MyCloudServiceName"/>
11: </ReservedIPs>
12: </AddressAssignments>
13: </NetworkConfiguration>
14: </ServiceConfiguration>