Skip to content

Instantly share code, notes, and snippets.

@astaykov
Created February 24, 2015 07:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save astaykov/19332d01a7976b9c515f to your computer and use it in GitHub Desktop.
Save astaykov/19332d01a7976b9c515f to your computer and use it in GitHub Desktop.
Move existing Azure VM to a Cloud Service with Reserved IP Address
$subName = "<your_subscription_name>"
$storageName = "<your_storage_account_name>"
$reservedIPname = "<pick_a_name_for_the_reserved_ip>"
$reservedIPlabel = "<pick_a_label_for_the_ip>"
$reservedIPlocation "<set_the_location>" # i.e. West Europe
$serviceName = "<cloud_service_name_of_the_deployed_vm>"
$vmName = "<namne_of_the_vm>"
$vnetSiteName = "<name_of_the_vnet_site>" # if the VM will be part of Virtual Network.
$pathToVMConfig "<enter local path where to save current vm configuration>"
Add-AzureAccount
Select-AzureSubscription $subName
Set-AzureSubscription -SubscriptionName $subName -CurrentStorageAccountName §storageName
New-AzureReservedIP –ReservedIPName $reservedIPname –Label $reservedIPlabel –Location $reservedIPlocation
Get-AzureReservedIP # just to confirm we have it
Export-AzureVM -ServiceName $serviceName -Name $vmName -Path $pathToVMConfig
Remove-AzureVM -ServiceName $serviceName -Name $vmName -Verbose
Import-AzureVM -Path $pathToVMConfig | New-AzureVM -VNetName $vnetSiteName -ServiceName $serviceName –ReservedIPName $reservedIPname
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment