TOTD: How to manually move Azure VMs to another subscription

Here is a new tip of the day. We’ll discuss only the Azure Resource Manager. Azure Service Management (ASM or classical) won’t be covered.

Azure portal has a simple built-in tool to migrate resources between subscriptions/resource groups and it’s available under Resource Group – Move

azure move in portal

Or using PowerShell :  Move-AzureRmResource

It’s also well described @MSDN and there are some main limitations that we need to consider:

  • Move in Azure Portal works only for subscriptions/resources groups in the same tenant (the most important!)
  • Not any resources can be migrated. For example, it’s not supported to move VPN Gateway or Recovery vaults. So we need to create and configure the new ones in the target subscription.
  • There are different limitations for ASM (classical deployments) and ARM. Check them before migration.

If the tenant IDs for the source and destination subscriptions are not the same, you can attempt to change the directory for the subscription. This operation requires Service Administrator which sometimes are not available for user. For example, migration from CSP to EA.
In this case, manual migration is required.

To get list of subscriptions and TenantIDs associated with them use PowerShell:

get azure subscriptions and tenants

In this example, the first two subscriptions are in the same tenant and migration between them can be done through Azure portal using Move option.

However, moving resources between the subscriptions “Visual Studio Premium..” and “Microsoft Azure Sponsorship” requires manual migration steps (look at the TenantID..they are different).

So, how to move? It’s quiet simple if you are familiar with AzCopy and Azure PowerShell.

The process of migration consists of several simple steps:

  • Prepare your target subscription (general services like storage accounts and networks)
  • Download and install AzCopy, stop VMs, copy VHDs of each VM to the target
  • Install AzureRM module, create VMs using the copied VHDs
  • Add additional resources such as VPN Gateways/S2S connections and Recovery vaults (optional)

Some details

1) To copy (asynchronously) VHDs use the following command

AzCopy /Source:<Source URI>  /Dest:<Dest URI>  /SourceKey:<Source Key> /Pattern:<sorcevhdname.vhd>

<Source Key>  is one of the access keys (Storage Account – Access Keys or use PowerShell):

List of all storage accounts in the source subscription


Get-AzureRmStorageAccount|Ft ResourceGroupName,StorageAccountName

list of azure storage accounts

List of source storage account keys (example). Use one of the keys value with AzCopy

Get-AzureRmStorageAccountKey -ResourceGroupName <resource group name> -Name <storage account name>|ft -AutoSize

azure storage account keys

To get URIs and VHDs name (Storage Account – Containers – <name of container>):

(Get-AzureRmStorageAccount -Name <stor acc name> -ResourceGroupName <rg name>|Get-AzureStorageContainer|Get-AzureStorageBlob).ICloudBlob.uri.AbsoluteUri

azure uri and vhds

Stop VM or VMs and run copy in AzCopy then. Wait while AzCopy finishes initiated process.

Tip: prepare script for all VMs before stopping them. simultaneous copies are allowed.

2) Open PowerShell ISE with installed AzureRM module, replace values (variables and subID) with yours and run:

#Open new Azure session
Login-AzureRMAccount

#Target subscription details
$sub=(Get-AzureRMSubscription -SubscriptionName "your subscription name" ).TenantId
Select-AzureRmSubscription -SubscriptionId $sub

#Variables
$rgname = "your rg name"
$vmsize = "required VM size <Example:Standard_A4>"
$vmname = "your vm name"
$locName="location (example:East US)"
$nicName="VMName_Nic"
$vnetName="Virtual Network Name"
$SubName = "Subnet Name"
$osDiskName = "vmdiskname"
$osDiskVhdUri = "https://destination.blob.core.windows.net/vhds/name.vhd"

#New VM config
$newvm = New-AzureRmVMConfig -VMName $vmname -VMSize $vmsize

#Get virtual network
$vnet=Get-AzureRmVirtualNetwork -Name $vnetName -ResourceGroupName $rgName

#Get subnet
$subnet = $vnet.Subnets | Where-Object { $_.Name -eq $SubName}

#New Public IP
$publicip=New-AzureRmPublicIpAddress -Name $nicName -ResourceGroupName $rgName -Location $locName -AllocationMethod Dynamic

#New nic for VM
$nic=New-AzureRmNetworkInterface -Name $nicName -ResourceGroupName $rgName -Location $locName -SubnetId $subnet.Id  -PublicIpAddressId $publicip.Id

#Update VM config
$newvm = Add-AzureRmVMNetworkInterface -VM $newvm -Id $nic.Id

#Attach copied disk to VM (sample. just one OS disk)
$newvm = Set-AzureRmVMOSDisk -VM $newvm -VhdUri $osDiskVhdUri -name $osDiskName -CreateOption attach -Windows

#Create VM
New-AzureRmVM -ResourceGroupName $rgname -Location $locName -VM $newvm

Verify that VM is running in the target subscription and all disks are attached.

Note: latest AzureRM (3.5.0) module doesn’t output status of VM creation (it’ll be corrected in future releases). Use Azure Portal instead.

FAQ

How to run synchronous copy in AzCopy?

Place /SyncCopy parameter to the end of the AzCopy command above. It ensures that the copy operation will get consistent speed. AzCopy performs the synchronous copy by downloading the blobs to copy from the specified source to local memory, and then uploading them to the Blob storage destination. It’s recommended to prepare VM in the source subscription and run AzCopy from there to avoid egress cost

Should I pay for traffic during migration?

If you are moving data within the same region, you don’t have to pay for it. It’s free. Additional costs required only for moving data between different regions.

What’s the maximum speed of data transferring?

It depends on VM and storage types. Basically, for standard accounts it’s up to 60 Mb/s. Premium storage accounts can provide throughput up to 200 Mb/s. In the real world throughput can vary widely.
Example: about 1 Tb were migrated in 14 hours between subscriptions with standard accounts, VMs with Ax size and within the same region

What is new in Failover Clustering in Windows Server 2016

Finally, I’d like to review what’s new in failover clustering in Windows Server 2016. Actually, I wrote this article a couple of months ago for Russian official Microsoft blog so if you are Russian you can go to this resource to read it in your native language.

Also, I described some of the new features before RTM-version (when only TPs were available) and almost all of them can be applied to Windows Server 2016 as well. It means there are no significant changes in RTM for them. I’ll provide a short description of such features and links to my previous posts with a detailed information.

And yes, of course, completely new functionality (Load Balancing, for instance) will also be described here

I have all of this in PDF format. Ping me in the comments/email and I’ll send to you the copy PDF has been shared 

Cluster OS Rolling upgrade

Cluster migration is usually a headache for administrators. It could be the reason of huge downtime (because we need to evict some nodes from old cluster, build the new one based on these nodes or new hardware and migrate roles from source cluster. So, in the case of overcommitment we won’t have enough resources to run migrated VMs). It’s critical for CSPs and other customers that have implemented SLA policy.

Windows Server 2016 fixes this by adding possibility to place Windows Server 2012 R2 and Windows Server 2016 nodes in the same cluster during upgrade/migration phase.

The new feature named as Cluster Rolling Upgrade (CRU) significantly simplifies overall process and allows us to successively upgrade existed nodes without destroying cluster. It helps to reduce downtime and any required costs (hardware, staff time and etc.)

Cluster Rolling Upgrade Windows Server 2016

The full list of CRU benefits is listed below:

  • Hyper-V virtual machine and Scale-out File Server workloads can be upgraded ONLY from Windows Server 2012 R2 to Windows Server 2016 without any downtime. Other cluster workloads will be unavailable during the time it takes to failover (for example, SQL Server with AlwaysOn FCI ~ 5 minutes of downtime)
  • It does not require any additional hardware (for example, you evicted 1 node of 4. The rest 3 nodes are online and they must have resources for workloads live migrated from evicted node. In this case zero-downtime is predicted)
  • The cluster does not need to be stopped or restarted.
  • In-Place OS upgrade is supported BUT Clean OS install is highly recommended. Use In-Place upgrading carefully and always check logs/services before adding node back to cluster.
  • A new cluster is not required. In addition, existing cluster objects stored in Active Directory are used.
  • The upgrade process is reversible until the customer crosses the “point-of-no-return”, when all cluster nodes are running Windows Server Technical Preview, and when the Update-ClusterFunctionalLevel PowerShell cmdlet is run.
  • The cluster can support patching and maintenance operations while running in the mixed-OS mode.
  • CRU is supported by VMM 2016 and can be automated through PowerShell/WMI

To get more details read my previous post that shows CRU in action (it’s been written for Technical Preview but can still be used with RTM)

Hint: get list of supported VM’s version by host (Get-VMHostSupportedVersion).

Supported VMs Version by Hyper-V Host

Cloud Witness

Failover cluster in Windows Server 2012 R2 can be deployed with an external disk or file share witness which must be available for each cluster nodes and it’s needed as a source of extra vote. As you may know, witness is highly recommended (I’d say it’s required!) for Windows Server 2012 R2 cluster regardless of a number nodes in it (dynamic quorum automatically decides when to use witness).

In Windows Server 2016 a new witness type has been introduced – Cloud Witness. Yes, it’s Azure-based and it’s specially created for DR-scenarios, Workgroup/Multi-Domain cluster (will be described later), guest clusters and clusters without shared storage between nodes.

Cloud Witness uses Azure Storage resources (Azure Blog Storage through HTTPS protocol. HTTPS port should be opened on all cluster nodes) for read/write operations. Same storage account can be used for different clusters because Azure creates a blob-file generated for each cluster with unique IDs. These blob-files are kept in msft-cloud-witness container and require just KBs of storage. So, costs are minimal and Cloud Witness can be simply used as a third site (“arbitration’) in stretched clusters and DR solutions.

Cloud Witness in Windows Server 2016

Cloud Witness scenarios:

  • Multi-Site clusters
  • Clusters without shared storage (Exchange DAG, SQL Always-On and etc.)
  • Guests clusters running on Azure and On-Premises
  • Storage Cluster with or without shared storage (SOFS)
  • WorkGroup and Multi-Domain Clusters (new in WS2016. It’ll be described later)

Continue reading “What is new in Failover Clustering in Windows Server 2016”