migrating existing Azure VMs to Azure Premium Storage - azure

i am having two VM'S which is under domain running erp application and database server. Both vm are in Standard D12 v2 (4 cores, 28 GB memory)template.
Now we need to move these VM's into premium disk. So How can i migrate existing Azure VMs to Azure Premium Storage.

I will recommend migrating to Managed Disk and you can migrate existing VMs using standard storage account to Managed Disk and Premium Storage account follow article below.
Migrate existing Azure VMs using standard unmanaged disks to Premium managed disks

We can migrate existing Azure VMs from standard storage account to Premium storage account, but we need to shutdown the VMs.
If we can shutdown the VMs, then we can follow those steps to migrate them:
1.Via Azure portal to create a premium storage account(new).
2.Shutdown Azure VMs, copy VHDs to premium storage account. we can use PowerShell, Azure storage explorer or Azcopy to copy VHDs to new storage account.
3.Just delete Azure VMs and keep the VHDs, Virtual Network, NIC, Public IP address and other settings.
4. Use new storage account to create new VMs, when we create new VMs, in the configure page, we select original Vnet and NIC to it.
5. After it complete, try to login those VMs and test
erp application, make sure that the VMs to run properly, then delete original VHDs and storage account.
Note:
When we use VHDs from new storage account to create VMs, we need to select VM disk type to SSD.
===========================================
Update:
1. stop Azure VM and delete the VM via Azure portal.
2. use Azcopy(Microsoft Azure storage command line) to copy VHD to new Azure premium storage account:
AzCopy /Source:https://vmdisks416.blob.core.windows.net/vhds /Dest:https://jasondisk999.blob.core.windows.net/vhds /SourceKey:key /DestKey:key /Pattern:jasonvm20170519131021.vhd
3. Use PowerShell to create new Azure VM:
PS C:\Users> $rgname = "vm"
PS C:\Users> $loc = "eastus"
PS C:\Users> $vmsize = "Standard_DS1_v2"
PS C:\Users> $vmname = "jason-newtest2"
PS C:\Users> $vm = New-AzureRmVMConfig -VMName $vmname -VMSize $vmsize
PS C:\Users> $nic = Get-AzureRmNetworkInterface -Name "jasonvm422" -ResourceGroupName $rgname
PS C:\Users> $nicId = $nic.Id
PS C:\Users> $vm = Add-AzureRmVMNetworkInterface -VM $vm -Id $nicId
PS C:\Users> $osDiskName = "jason-newtest"
PS C:\Users> $osDiskVhdUri = "https://jasondisk999.blob.core.windows.net/vhds/jasonvm20170519131021.vhd"
PS C:\Users> $vm = Set-AzureRmVMOSDisk -VM $vm -VhdUri $osDiskVhdUri -name $osDiskName -CreateOption attach -Linux
PS C:\Users> New-AzureRmVM -ResourceGroupName $rgname -Location $loc -VM $vm
WARNING: Since the VM is created using premium storage, existing standard storage account, vmdiag614, is used for boot diagnostics.
RequestId IsSuccessStatusCode StatusCode ReasonPhrase
--------- ------------------- ---------- ------------
True OK OK

Related

Copy Azure Managed Image from Azure Comercial to Azure China

We have a custom Managed Image that we built from Windows VM in Azure. We need to copy that Managed Image to China and create VMs from it. Unfortunately, we are unable to connect to VMs created from copied .vhd. The steps we did:
1. Created VM in Europe from custom Managed Image.
2. Ran Sysprep.
3. Exported Managed Disk, and uploaded .vhd to Storage Account in China.
4. Created VM from that image.
The problem is we are not able to RDP to that VM.
What is the proper way to do it? (connection time out)
We can't recreate that Image in China, because we need that Image to be consistent with the image we have in Europe.
A generalized VHD has had all of your personal account information removed using Sysprep. If you intend to use the VHD as an image to create new VMs. You should create a new user name and password to use as the local administrator account.
The following PowerShell script shows how to set up the virtual machine configurations and use the uploaded VM image as the source for the new installation.
# Enter a new user name and password to use as the local administrator account
# for remotely accessing the VM.
$cred = Get-Credential
# Name of the storage account where the VHD is located. This example sets the
# storage account name as "myStorageAccount"
$storageAccName = "myStorageAccount"
# Name of the virtual machine. This example sets the VM name as "myVM".
$vmName = "myVM"
# Size of the virtual machine. This example creates "Standard_D2_v2" sized VM.
# See the VM sizes documentation for more information:
# https://azure.microsoft.com/documentation/articles/virtual-machines-windows-sizes/
$vmSize = "Standard_D2_v2"
# Computer name for the VM. This examples sets the computer name as "myComputer".
$computerName = "myComputer"
# Name of the disk that holds the OS. This example sets the
# OS disk name as "myOsDisk"
$osDiskName = "myOsDisk"
# Assign a SKU name. This example sets the SKU name as "Standard_LRS"
# Valid values for -SkuName are: Standard_LRS - locally redundant storage, Standard_ZRS - zone redundant
# storage, Standard_GRS - geo redundant storage, Standard_RAGRS - read access geo redundant storage,
# Premium_LRS - premium locally redundant storage.
$skuName = "Standard_LRS"
# Get the storage account where the uploaded image is stored
$storageAcc = Get-AzureRmStorageAccount -ResourceGroupName $rgName -AccountName $storageAccName
# Set the VM name and size
$vmConfig = New-AzureRmVMConfig -VMName $vmName -VMSize $vmSize
#Set the Windows operating system configuration and add the NIC
$vm = Set-AzureRmVMOperatingSystem -VM $vmConfig -Windows -ComputerName $computerName `
-Credential $cred -ProvisionVMAgent -EnableAutoUpdate
$vm = Add-AzureRmVMNetworkInterface -VM $vm -Id $nic.Id
# Create the OS disk URI
$osDiskUri = '{0}vhds/{1}-{2}.vhd' `
-f $storageAcc.PrimaryEndpoints.Blob.ToString(), $vmName.ToLower(), $osDiskName
# Configure the OS disk to be created from the existing VHD image (-CreateOption fromImage).
$vm = Set-AzureRmVMOSDisk -VM $vm -Name $osDiskName -VhdUri $osDiskUri `
-CreateOption fromImage -SourceImageUri $imageURI -Windows
# Create the new VM
New-AzureRmVM -ResourceGroupName $rgName -Location $location -VM $vm
Ref: Upload a generalized VHD to Azure to create a new VM

Change the boot diagnostic storage account of azure virtual machine

I have enabled a diagnostic storage account for my virtual machine. Now I want to change the diagnostic storage account. How do I do it in portal / PowerShell?
I can see that we have a cmdlet - "Set-AzureRmVMBootDiagnostics", however, this is not updating the diagnostic storage account to a new one.
In specific:
My current diagnostic storage is "ibmngeus2" and I would like to change to "sqlbackupacct".
In the Azure portal, you should be able to click on the boot diagnostics section of the virtual machine, and then click the settings, and then click the storage account section to change the storage account. Keep in mind that the new storage account you want to use must be in the same subscription and location or it will not show up as one you can choose.
I got the settings under the "Boot Diagnostic" option under the Virtual machine pane.
In PowerShell (with the now-deprecated AzureRM module), you can do this:
Get-AzureRmVM <Stuff to filter the VMs you want go here> | Set-AzureRmVMBootDiagnostics -Enable -ResourceGroupName <storage-account-rg> -StorageAccountName <storage-account-name> | Update-AzureRmVM
This will get the VM objects, change the setting and apply the change.
Example, to update all VMs' diag storage account to bucket in RG mygroup:
Get-AzureRmVM | Set-AzureRmVMBootDiagnostics -Enable -ResourceGroupName mygroup -StorageAccountName bucket | Update-AzureRmVM
(You probably want to filter more...)
For the new Az module, the commands would change to: (same warnings as above will apply)
Get-AzVM <Stuff to filter the VMs you want go here> | Set-AzVMBootDiagnostic -Enable -ResourceGroupName <storage-account-rg> -StorageAccountName <storage-account-name> | Update-AzVM
Get-AzVM | Set-AzVMBootDiagnostic -Enable -ResourceGroupName mygroup -StorageAccountName bucket | Update-AzVM
(There is a deprecation warning for the plural version of the command - this uses the new name, but the warning still shows)

Azure Scaleset - is there a Get-AzureRmVmssDiagnosticsExtension

Is there a Get-AzureRmVmssDiagnosticsExtension. How do I get if a scale set has diagnostics enabled and what storage it is using.
As far as I know, there is no command to get the storage account directly.
But we can use PowerShell to the information of vmss, like this:
PS C:\Users> get-azurermvmss -ResourceGroupName vmss -VMScaleSetName vmss

Attaching restored OS disk to existing VM

I have one VM with a daily backup scheduled. Today I deleted a file in that VM and changed some configuration. I restored yesterday's data disk from my recovery service vault and changed the names of the recovered data disk.
Now I want to attach yesterday's restored backup to my existing VM. Is it possible?
If not then suppose I delete my VM but I keep its network interface card. I can create a new VM from restored VHDs using ARM templates but how can I assign an existing NIC to my new VM?
Also, I have added this VM to my domain controller. If I recreate the VM, do I need to add the new VM to the domain controller or will it work normally?
Now I want to attach yesterday's restored backup to my existing VM. is
it possible?
Yes, we can attach this restore disk to your existing VM, then we can find the disk in your existing VM.
I delete VM but I keep network interface card for the VM, now I can
create VM from restored VHD's using ARM templates but how to assign
exiting NIC in the new VM?
Yes, we can use PowerShell to create a VM with existing NIC and VHD, here is an example:
$rgname = "jason-newgroup"
$loc = "japaneast"
$vmsize = "Standard_DS1_v2"
$vmname = "jason-newtest2"
$vm = New-AzureRmVMConfig -VMName $vmname -VMSize $vmsize
$nic = Get-AzureRmNetworkInterface -Name "NICname" -ResourceGroupName $rgname
$nicId = $nic.Id
$vm = Add-AzureRmVMNetworkInterface -VM $vm -Id $nicId
$osDiskName = "jason-newtest"
$osDiskVhdUri = "https://jasonnewgroupdisks912.blob.core.windows.net/vhds/jason-newtest201681285042.vhd"
$vm = Set-AzureRmVMOSDisk -VM $vm -VhdUri $osDiskVhdUri -name $osDiskName -CreateOption attach -Windows
New-AzureRmVM -ResourceGroupName $rgname -Location $loc -VM $vm
if I recreate the VM do I need to add new VM to domain controller or
will it work normally?
Yes, the new create VM (restore) will add to the domain controller, we don't need to add the VM to domain controller again.

How to increase size of OS disk in Windows Azure using Powershell

I want to increase size of OS disk in Windows Azure using Powershell or any other tool. Please help
Regards
Umair
Resize the OS drive
Open your Powershell ISE or Powershell window in administrative mode and follow the steps below:
Sign-in to your Microsoft Azure account in resource management mode and select your subscription as follows:
Login-AzureRmAccount
Select-AzureRmSubscription –SubscriptionName 'my-subscription-name'
Set your resource group name and VM name as follows:
$rgName = 'my-resource-group-name'
$vmName = 'my-vm-name'
Obtain a reference to your VM as follows:
$vm = Get-AzureRmVM -ResourceGroupName $rgName -Name $vmName
Stop the VM before resizing the disk as follows:
Stop-AzureRmVM -ResourceGroupName $rgName -Name $vmName
And here comes the moment we’ve been waiting for! Set the size of the OS disk to the desired value and update the VM as follows:
$vm.StorageProfile.OSDisk.DiskSizeGB = 1023
Update-AzureRmVM -ResourceGroupName $rgName -VM $vm
The new size should be greater than the existing disk size. The maximum allowed is 1023 GB.
Updating the VM may take a few seconds. Once the command finishes executing, restart the VM as follows:
Start-AzureRmVM -ResourceGroupName $rgName -Name $vmName
And that’s it! Now RDP into the VM, open Computer Management (or Disk Management) and expand the drive using the newly allocated space.
pasted from: https://learn.microsoft.com/en-us/azure/virtual-machines/virtual-machines-windows-expand-os-disk
i have done this by using below command on windows azure powershell latest version. Please note old version of powershell doesnot support this command .
Update-AzureDisk -DiskName [Disk-Name] -Label [DiskLabel]-ResizedSizeInGB 1020

Resources