Giter Club home page Giter Club logo

azure-vm-clone's Introduction

Azure-VM-clone

Azure Powershell script to clone VMs accross Subscription or within the same.

This script is based from below work. http://gallery.technet.microsoft.com/scriptcenter/Copy-a-Virtual-Machine-83d192a5#content

SYNOPSIS

This cmdlet takes an existing virtual machine, makes a copy of its disks in the local storage account and then copies the virtual machine to a seperate subscription. Running this script can take several minutes and up to hours if copying a virtual machine to a remote storage account.

Ensure the source subscription and the destination subscription are configured for PowerShell access.

Verify by running the following command to ensure that both subscriptions are listed: Get-AzureSubscription | select SubscriptionName

New functionality added by David Sabater:

  1. Fixed issues with Location variable with new Azure SDK version
  2. Modify disk name appending VM new name to be able to copy VM within same subscription and renaming VM to new one

DESCRIPTION

This script works by creating a copy of all of the disks of the virtual machine to a container in the same storage account. You may optionally specify -ShutdownVM to shut the virtual machine down to ensure the backup is clean first.

Once the disks are backed up locally the script validates that the remote cloud service name, storage account, virtual network and subnet are all accessible from the current configuration.

Once validation is complete the script will copy the disks from the backup in the source storage account to the destination storage account.

Once the copy is complete the script will register the disks in the subscription with the same disk names but appending the new Virtual Machine name to match new Virtual Machine cloned, this gives the capability to clone VM within same Subscription

The script next will export the virtual machine settings to a local file on the file system and import them into the target subscription and create the virtual machine with the new name selected.

EXAMPLE

Copy a virtual machine to a different subscription

.\vmcopy.ps1 -SourceSubscription "source subscription" -DestinationSubscription "destination subscription" -VirtualMachineName "existingvmname" -SourceServiceName "sourcecloudservice" -DestinationVirtualMachineName "destinationvirtualmachineName" -DestinationServiceName "destinationcloudservice" -DestinationStorageAccount "destinationstorageaccount" ` -Location "West US"

Copy a virtual machine to a different subscription and specify an existing virtual network and subnet.

.\vmcopy.ps1 -SourceSubscription "source subscription" -DestinationSubscription "destination subscription" -VirtualMachineName "existingvmname" -SourceServiceName "sourcecloudservice" -DestinationVirtualMachineName "destinationvirtualmachineName" -DestinationServiceName "destinationcloudservice" -DestinationStorageAccount "destinationstorageaccount" -VNETName "DestinationVNET" -SubnetName "DestinationSubnet"

azure-vm-clone's People

Contributors

dsdinter avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.