torsdag den 13. september 2012

Azure PersistentVM loosing network connectivity

I have several time experience that my VM’s suddenly loose all connectivity in azure. in the forums several people have complained about this. Your machine will show as running in the portal, but you cannot connect to it remotely. Some say that waiting a few hours makes it come back, but not for me. If you have several machines connected to a virtual network, you can ping and connect to the machine, but you cannot browse/resolve DNS, or connect to anything externally, even using IP addresses from the machine.

If you try and export the VM, delete it, and import the VM, it will fixes the problem.

$servicename = 'superservice'
$vmname = 'superserver01'

Export
-AzureVM -ServiceName $servicename -Name $vmname -Path "c:\VMConfig\$vmname.xml"
Remove
-AzureVM -ServiceName $servicename -Name $vmname
Remove
-AzureService -ServiceName $servicename
$vm = Import-AzureVM -Path "c:\VMConfig\$vmname.xml"
New
-AzureVM -VM $vm -ServiceName $servicename -Location 'North Europe'


How ever if you want to keep the Virtual IP, you don’t want to delete the Hosted Service.




New-AzureVM -VM $vm -ServiceName $servicename


This will fail if the machine was part of a Virtual Network. ( the machine will have a Subnet defined in the configuration, but the azure REST API wont know what Network that subnet belongs too (even if you only have one) so if you get


New-AzureVM : HTTP Status Code: BadRequest - HTTP Error Message: The virtual network name cannot be null or empty.


do it like this


$servicename = 'superservice'
$vmname = 'superserver01'
$vmname = 'supercoolnetwork'

Export
-AzureVM -ServiceName $servicename -Name $vmname -Path "c:\VMConfig\$vmname.xml"
Remove
-AzureVM -ServiceName $servicename -Name $vmname
$vm = Import-AzureVM -Path "c:\VMConfig\$vmname.xml"
New
-AzureVM -VM $vm -ServiceName $servicename -VNetName $networkName