4

We have an azure virtual network with a web role, worker role and a dedicated sql VM. Currently we're using the VM dns name in the database connection string. I was thinking it would be better to update the connection string to use the private ip address to skip the name resolution, mydbserver.cloudapp.net to 10.0.0.1.

Since all virtual machines have to use DHCP is there a chance the private ip will change? If so is there anyway to address this? Thanks

NullReference
  • 4,404
  • 12
  • 53
  • 90

2 Answers2

3

The SQL Server VM will have a persistent private IP within the Virtual Network.

From Windows Azure Virtual Network Overview:

Persistent private IP addresses: Virtual machines within a VNet will have a stable private IP address. We assign an IP address from the address range you specify and offer an infinite DHCP lease on it. So the IP address will stay with the virtual machine for its lifetime.

Jim O'Neil
  • 23,344
  • 7
  • 42
  • 67
  • hm, it is not mentioned that if the VM goes down for some reason - planned maintenance, OS Updates that require restart, etc, the IP Address will be "freed". And if another VM pops online booting in the same sub-net, that new VM will get the freed IP Address. – astaykov Jun 17 '13 at 21:55
  • What would "persistent" mean otherwise then? That the IP doesn't change while the VM is running - that would seem a given :). It's "lifetime" is defined by its deployment, as long as it's deployed (and you don't re-deploy) the IP address persists. That said, scan further down in the reference and you'll see "You can set up secure IPv4 networks that are fully contained within Windows Azure by using persistent IP addresses. **This means that the internal IP address of your virtual machines will remain persistent and will not change, even when you restart a virtual machine.**" – Jim O'Neil Jun 18 '13 at 00:39
  • You know that if you shut down the instance in the new way to not incur charges (which currently is only available and only option in the Portal), the IP lease will be released! Then it might be got up by another (new) booting VM. – astaykov Jun 20 '13 at 06:12
  • You're saying this is true when the VM is part of a virtual network? The VNET is the key part here. I have not tested this scenario since the new capability came on line, but would agree that this case would definitely need to be documented. – Jim O'Neil Jun 20 '13 at 19:51
  • True - yes. Should be documented - yes. – astaykov Jun 20 '13 at 20:57
  • It is documented on the page [Windows Azure Virtual Network Overview](http://msdn.microsoft.com/en-us/library/windowsazure/jj156007.aspx) that @JimO'Neil has referenced it specifically says: "Important: When a virtual machine is Stop (Deallocated), it does not retain its IP address." I interpret this to mean that if you shut down your VM via the Portal so that your VM is in the Stop Deallocated state (not just the stopped state) the IP will be released regardless whether it is part of a Virtual Network or not. If you just shut down your VM to the Stop state then your IP will still be retained. – neodymium Jan 13 '14 at 03:50
1

to be extra safe, you can set a static vnet IP that guarantees that it never changes: http://windowsitpro.com/windows-azure/set-azure-vm-static-ip-address

kennydust
  • 1,135
  • 15
  • 17