Forked from Kevin-Bronsdijk/Move_Azure_Virtual_Machine_to_a_different_data_center_1.ps1
Created
April 25, 2016 22:03
-
-
Save TheBigBear/a7d881f057200078fcb77a34f1b878ea to your computer and use it in GitHub Desktop.
Move_Azure_Virtual_Machine_to_a_different_data_center
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Get-AzureVM -ServiceName "name_cloud_service" -Name "vm_name" | |
Get-AzureVM -ServiceName "name_cloud_service" -Name "vm_name" | Get-AzureEndpoint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Get Associated VHD | |
Get-AzureDisk | Where-Object {$_.AttachedTo.RoleName –eq "vm_name" } | SELECT MediaLink |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Stop-AzureVM -Name "vm_name" -ServiceName "name_cloud_service" -Force | |
Remove-AzureVM -Name "vm_name" -ServiceName "name_cloud_service" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
New-AzureStorageAccount -StorageAccountName "storage_name" -Label "storage_name" -Location "your_location" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Source storage account | |
$context1 = new-azurestoragecontext -storageaccountname "name_source_account" -storageaccountkey "key_source_account" | |
#Destination storage account | |
$context2 = new-azurestoragecontext -storageaccountname "name_destination_account" -storageaccountkey "key_destination_account" | |
#Initiate copy this might take a while | |
Start-AzureStorageBlobCopy -SrcContainer "vhds" -SrcBlob "name_as_found_in_step_one.vhd" -SrcContext $context1 -DestContainer "vhds" -DestBlob "my_destination_name.vhd" -DestContext $context2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$context2 = new-azurestoragecontext -storageaccountname "name_destination_account" -storageaccountkey "key_destination_account” | |
Get-AzureStorageBlobCopyState -Blob "file_name.vhd" -Container "vhds" -Context $context2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$context2 = new-azurestoragecontext -storageaccountname "name_destination_account" -storageaccountkey "key_destination_account” | |
Stop-CopyAzureStorageBlob -Blob "file_name.vhd" -Container "vhds" -CopyId "Value_from_Get-AzureStorageBlobCopyState" -Context $context2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Additional required step | |
Set-AzureSubscription -SubscriptionName "your_subscription" -CurrentStorageAccount "name_storage_account" | |
#Build VM Config | |
$vmdetails = New-AzureVMConfig -Name "vm_name" -InstanceSize your_instance_size -ImageName "name_of_the image" | |
#Additonal settings... | |
#Create the VM | |
New-AzureVM –ServiceName "name_cloud_service" -Location "location" -VMs $vmdetails |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment