creating image windows azure without deleted virtual machine? - azure

I have an instance medium in windows azure.
I need an image to make new instance large, so when I create an image, It say you must delete it as part of operation.
So, how can i make image instance medium without deleting current virtual machine??
note: Amazon cloud service can make image without deleting instance. That includes microsoft server.
Actually how to do create image with minimum downtime. That's the true purpose of this question.

There are a couple of objectives I read from this. The first is that you want to make a medium instance large. You can change the size of a virtual machine without deleting it. Go to the configure tab for the VM and change the size. This will require a reboot, but it will keep your virtual machine in tact.
The second is to create an image with minimum downtime. As you know, this is not possible without destroying your existing VM. The details of sysprepping a machine are the reason (won't go into those details here). You could create a new virtual machine from your existing one and sysprep that copy though. At least that way you're not losing any downtime while you're creating the image. Not sure how helpful that is for your scenario. Personally, I would just re-size your existing VM if that's all you need. Regardless, here are the steps.
Copy the VHD to a backup container in the same storage account.
Create a new disk from the copy of the VHD.
Create a new virtual machine based off the new disk. You can also specify the size at this step too.
Login and sysprep the new virtual machine.
Shutdown and capture the image of the new virtual machine.
This will get you an image without impacting your existing VM.

There are two types of images: Specialized and Generalized.
You can check the detail in VM Image.
For your scenario, you want to change the size of your vm. So you'll need a Generalized image which has been removed the original provision data, such as vm size, the admin user password, etc.
But in order to capture a Generalized image, you have to do deprovision on the original running vm.
For Windows in Azure:
%windir%\system32\sysprep\sysprep.exe /generalize /shutdown /oobe
For Linux in Azure:
$ sudo waagent –force –deprovision
$ shutdown –h now
Note: After deprovison, the original VM is useless for you and just like an orphan, and you lost the control for it since it has been removed a lots of original provision data. That's why Azure deletes the vm automatically after capturing image successfully.
I agree with you AWS EC2 is more powershell than Azure. A lot of services are inconvenient in Azure.

There is VHD blob container which contains your VM OS disk and VM data disks. You can copy the data disks and attach to any VM.
When you are creating the image, you need to do sysprep which deletes everything from your VM even login. So anyways your VM is of no use. Now once the image is there you can create your VM selecting the image which you have created and data disk if you want old data to be there also. And you can create as many copies as you want.

Related

Easy backup and restore VM's when using Azure

I have a couple of VMs that I want to backup and restore easily and often. Preferably as a group.
I have tried default Azure backup and restore but noticed that it doesn't seem to do much. It is easy to create and schedule backups but it is not clear to me how these backups can be used to bring a VM back to its original state.
The use cases for the default backup / restore seem to be very different from what I expected. I expected something somewhat similar to VirtualBox: take a snapshot and then restore takes the VM back to the snapshot.
Restore of VM in Azure does not seem to be a supported use case. I think the idea is more to clone / duplicate the machine.
The default "restore" is a feature to create another VM because it you try to restore Azure shows an error message
A virtual machine with the same already exists in the selected resource group. Please change the virtual machine name or select a new resource group.
There is an option to restore disks. This seems to work at first. Restore job completes successfully but nothing it restored. The file system is the same as before restore.
There is no detailed log so there is no way to determine what is happening. There is only exit status: success restore completed successfully.
Are there other ways to mimic VirtualBox functionality? Take snapshots and restore VM's using such snapshots?
Does MS have plans to enhance backup in such way that it also supports restore?
Snapshot works by capturing image state of a virtual machine. In Azure, you can snapshot your VHD and restore that snapshot whenever you'd like. Get started with snapshot here https://learn.microsoft.com/en-us/azure/virtual-machines/windows/snapshot-copy-managed-disk
Disk snapshot works best in case your virtual machine uses one disk (for the OS). Or if that virtual machine has more than one disk, disk snapshot is still useful, but takes time and may result disk management overhead. In that case, you could go with image generalization to capturing the whole virtual machine's state at once using tool like sysprep (https://learn.microsoft.com/en-us/azure/virtual-machines/windows/capture-image-resource)
From your screenshot, the problem is exactly what is highlighted in red. You cannot overwrite your virtual machine to the existing one in the same resource group. You must restore it somewhere else.
Azure Site Recovery and Backup is designed to work with large deployment of virtual machines, with some capabilities of automation and disaster recovery.

Azure - Is there a way to generalize the Image after capturing it already?

Recently, I tried to generalize a specific VM in Azure to be used as an image for a future scale set.
After doing that (the wrong way), I tried to create a VM using this image and I got this error -
"OS Provisioning for VM 'MyVM_10' did not finish in the allotted time. However, the VM
guest agent was detected running. This suggests the guest OS has not been properly prepared to be used as a VM image
(with CreateOption=FromImage). To resolve this issue, either use the VHD as is with CreateOption=Attach or prepare it
properly for use as an image"
Which means that I did not sysprep it properly.
Is there a way to sysprep it now? Or do I have to start all over again and there is no use of the image file that was created in this process?
You could stop your original VM and use this image to create a VM. Then I think you will not meet this error log. Then you could login this VM and sysprep it and use this VM to create a new image.
If it does not work, I suggest you could download this image's VHD to local. Using this VHD to create a VM on Hyper-V and sysprep it. Then upload this VHD to Azure and use this VHD to create a image. See this link.

Unable to create an azure image in ARM

I have uploaded a back up of onprem OS disk to azure RM storage account. I want to create an image out of that os disk to provision vms in azure.
Please let me know if that is possible ?
Assuming your base system is running Windows, and you don't want to sysprep the machine, you're trying to create what's called a Specialized image in Azure. The best steps to follow to complete this are:
Create the Specialized image
Create a VM from an image
The first thing that you need to make sure that the disk is in correct format i.e VHD for azure. There are many third party tools available to convert the disk to VHD (very easy if it's hyper v machine).
Secondly do create the necessary infrastructure in azure like storage account to upload the disk and virtual network that would connect to your machine, resource group etc. Also this is currently only possible through powershell and not through portal.
Azure migarte has now made it very to migrate large number of vms if you are considering a production( much better than its was last year).
The question says unable to migrate is disk so I assume you must have gone through Microsoft document and than must have faced problem. Can you provide me the error you got while uploading?

I would like to change Microsoft Azure Virtual Machine size without losing my data

I am using two Microsoft Azure Virtual Machines (marked as classic), both running on Linux. One is used for test purposes and internal demos, the other is production and running few of clients' instances.
What I would like to do is change the size of Virtual Machine. I understand this is quite common process and can easily be done from the Azure Management Portal and that this is not affecting data. However, when I have changed the size of our testing machine, exactly this has happened and we have lost all data.
Azure Support answer received was:
"We recommend you delete the VM by keeping the attached disks and create a new VM with the required size." Not sure why this would be better?
Any data stored on the ephemeral (internal-to-chassis) scratch disk is at risk, as it's a non-durable disk (and will in all likelihood be destroyed/recreated upon resizing a VM).
The only way to have durable data is to use Azure Storage (blobs, vhd as attached disk, Azure File storage) or external database. Azure Storage is durable (minimum 3 copies), and is not stored with your VM.
One more thing: The VM's OS Disk is a VHD in Azure Storage (so the OS disk is durable, just like attached vhd's).
You have more than one way to do that and keep in mind what David said, data on OS disks, attached disks and blobs is the only durable one.
To prevent losing data and since you're using Classic VMs, you can do the following:
1- Go to your VM on portal and capture an image out of it.
2- Go to your new image and create a new VM out of it, while specifying the new specs that you need.
3- When done, connect to your new VM while keeping the old one without termination.
4- Check if all your data is there, if yes, then you can remove the old one. (In case you need the old IP, you can still assign it to the new one).
Cheers.

Unable to recreate Azure VM deleted after going over free limit

I had two VMs running in azure and went over my free limit for this month. I enabled the ability to charge my account and found they were gone.
The VM disks are still there but the VMs themselves have been made into hosted services. To recreate the VM I deleted the hosted service, then went to the create new VM dialog like I've seen others post previously. Under the "create from disk" option I do not see either of my OS disks as options to create a VM. Is this the right way to recreate VMs or am I missing something?
Also of note, the disks still show up as attached to the deleted VMs in the portal.
As you mentioned that your OS VHD still shows connected with deleted VM, you would need to take care that first. You can run the BreakLease.ps1 Powershell script in this forum discussion to remove the lease first and then use the Os disk VHD to create a new OS Image. Finally you can use the new OS image to create your new Virtual machine.
Alternatively if you just want to reuse the same OS disk vhd to create a new virtual machine, you can follow the blog below and look for section at the bottom "To reuse the OS VHD blob to create OS Image" to copy the blocked OS blob into a new blob and then use it:
Using OS disk VHD to create a new Virtual Machine if OS VHD is still on lease in Windows Azure Virtual Machines

Resources