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

Azure presentation and technical materials

azure iaas

I’ve received a plenty useful links to my mail today. By using these links you can download Azure related materials to improve your understanding the process of planning and selling Azure services. There are multiple presentations with different levels (from 50 to 200/300) and technical documentation kits.

Azure and CSPs

How partners can make money with Azure IaaS

This presentation provides an overview of how partners can make money with Azure IaaS.

N + DV2 VMs are also described (but a very shortly)

Getting started on CSP for Azure

This FAQ style document is a “Getting Started guide” for Microsoft Azure services in the CSP program.

Overview of CSP in Azure

This presentation provides an overview of the Azure in CSP program

Case Studies 

Azure CSP partner case study – Dell and Takeform

Azure CSP partner case study – Datapipe

Azure CSP partner case study – Lumen21

Azure CSP partner case study – ProserveIT and BC Milk

Azure CSP partner case study – SaaSplaza

Miscelanneous

Active Directory from on-premises to the cloud – Azure AD whitepapers (it’s clear)

Hybrid IaaS technical guides (hope it’s clear too | tech.guides level 300 are perfect)

Hybrid IaaS GTM materials

IoT business documentation

This zipped folder includes an overview of Analytics on Azure, including the IoT vision and data platform scenarios

Internet Of Things (IoT) technical documentation

This document provides technical guidance on deploying cloud services for IoT

Application dev/test technical guides

These documents provide a technical overview of application development and testing.

Application dev/test business documentation

This zipped folder contains documents that provide an overview of application dev/test offerings for partners.

Analytics technical guides

This zipped folder provides technical guidance for analytics on Azure

Analytics business documentation

This zipped folder includes an overview of Analytics on Azure, including the Analytics vision and data platform scenarios.

Contoso in the Microsoft Cloud

[PDF, VSD] See how a representative global organization has adopted all of Microsoft’s cloud offerings, including Office 365, Azure, Dynamics 365, and Intune.

SQL Services

Azure SQL DB technical documentation

This zipped folder contains best practices and deployment documentation for Azure SQL database.

Azure SQL DB business documentation

This zipped folder contains presentations that provide guidance on Azure SQL database – business discussions.

SQL in Azure VMs GTM materials

Videos/solution templates

SQL in Azure VMs technical documentation

Best practices and deployment documentation

SQL in Azure VMs business documentation

This zipped folder contains presentations that provide guidance on SQL in Azure VMs – business discussions.

Power BI technical guides

This zipped folder provides technical guidance for deploying Power BI, creating dashboards, and other technical details of managed services.

Power BI business documentation

This presentation provides guidance on incorporating Power BI into your managed services practice through CSP.

RDS 2016 in Azure

RDS 2016 on Azure laaS Technical Guidance Deck

[PPTX] RDS 2016 on Azure IaaS Scenario, Offer and Deployment Approach

RDS 2016 on Azure laaS Technical Guidance Document

[DOC] Great Technical guidance for CSP partners

RDS 2016 on Azure laaS Landing Page Framework

This is the Remote Desktop Services (RDS) 2016 on Azure IaaS Landing Page Framework for HMSPs. Please use the content and modify the format to fit your website template

RDS 2016 on Azure laaS Hoster Partners Messaging Framework

Use this document as a guide as you develop relevant communications. This is a reference document, intended to inform the work of marketing and sales professionals.

RDS 2016 on Azure laaS Sales Datasheet

Explains the value of RDS 2016 on Azure IaaS (DOC)

RDS on Azure Laas BDM Deck

[PPTX] RDS on Azure Laas BDM Deck

DR and BaaS

Backup and Disaster Recovery technical documentation

These documents provide a technical overview of Backup and Disaster Recovery solutions.

Backup and Disaster Recovery business documentation

This zipped folder contains documents that provides an overview of backup and disaster recovery offerings for partners.

Backup and Disaster Recovery GTM materials

Disaster Recovery for SQL business documentation

This zipped folder contains presentations that provide guidance on disaster recovery for SQL – business discussions.

Disaster Recovery for SQL GTM materials

Campaigns, sample service offers, and templates

Disaster Recovery for SQL technical documentation

This zipped folder contains technical documentation for disaster recovery for SQL, along with a SQL 2014 hybrid kit.

SQL Backup to Azure GTM materials

This zipped folder contains campaigns, sample service offers, and templates for SQL backup to Azure.

SQL Backup to Azure business documentation

This presentation provides guidance on SQL Backup to Azure – business discussions

SQL Backup to Azure technical documentation

Technical deployment kit with deployment guidance of SQL backup to Azure.