Moving existing resources between New Resource Groups (the new way!!) using Powershell


# Script Created by Craig SCCM N00B #

# v1 12.01.2016 #

#####################################################################
# Import the Azure Cmdlets #
#####################################################################

Import-Module Azure

Import-Module AzureRM

#####################################################################
# Login to Azure Portal using your Credentials #
#####################################################################

Login-AzureRmAccount

#####################################################################
# Enter your Subscription Name #
#####################################################################

$Subscr = Read-Host "Enter your Subscription Name"
Select-AzureRmSubscription -SubscriptionName $Subscr

#####################################################################
# Move Resource #
#####################################################################

$resource = Get-AzureRmResource -ResourceName Resouceyouwanttomove -ResourceGroupName OldResGrpName
Move-AzureRmResource -DestinationResourceGroupName NewResGrpName -ResourceId $resource.ResourceId

Unfortunately not all services currently support the ability to move resources (12.01.2016)

Services that are supported moving to both a new resource group and subscription are:

  • API Management
  • Automation
  • Batch
  • Data Factory
  • DocumentDB
  • HDInsight clusters
  • Key Vault
  • Logic Apps
  • Mobile Engagement
  • Notification Hubs
  • Operational Insights
  • Redis Cache
  • Search
  • SQL Database server (Moving a server also moves all of its databases. Databases cannot be moved separately from the server.)
  • Web Apps

The services that support moving to a new resource group but NOT a new subscription are:

  • Virtual Machines (classic)
  • Storage (classic)
  • Virtual Networks
  • Cloud Services

The services that currently do not support moving a resource are:

  • Virtual Machines (This sucks the most)
  • Storage (This sucks an awful lot)

I recently watched a Video with Cheryl McGuire on Azure and even she said that they are changing things all the time…which is a pain but if you can keep on top of it, eventually Azure will be a brilliant Cloud Based Platform (minus the constant changes)

Advertisements