I have to create an Image from an existing VM using Packer.This is the link I'm following to do so.
Now I have few doubts in this before proceeding further.
Can I run all these commands remotely.
If yes, where should I install Packer , is it on client Machine or remote machine?
If it has to be installed on remote machine, from which the image is being created, is there any workaround for that. I will not have access to install anything on the remote machine.
No where the VM details are not mentioned. Does that mean, it will automatically take the VM details when we run the commands on the VM?
Where can I see the output of the whole process? Will it be available in azure portal?
Any inputs on the above questions are appreciated.Thanks!
First of all, there is something you have misunderstood about Packer.
The Azure builder can create either a VHD, or a managed image. If you
are creating a VHD, you must start with a VHD. Likewise, if you want
to create a managed image you must start with a managed image.
It means you must create the image from the image or VHD, not VM.
The answer to your question.
Yes, you can run the command remotely, just like Azure CLI.
You can install Packer on your on-premise machine.
From the description of Packer, it just needs the image information.
You can see the output where you run the Packer command.
Update
When you want to create the image from VHD file, you can make an instead:
"image_publisher": "Canonical",
"image_offer": "UbuntuServer",
"image_sku": "16.04.0-LTS",
Into
"image_url": "https://my-storage-account.blob.core.windows.net/path/to/your/custom/image.vhd",
If your vm is managed by Azure, you can pay attention to the option of custom_managed_image and images in Azure. Hope this will be helpful.
Related
I am writing a program that uploads a file to Azure blob storage, creates a virtual machine, and now I want to download and execute that file within the VM. For that I am trying to execute the command az storage blob download <parameters> in the VM, but unfortunately az is not recognized. How can I enable that the Azure CLI is (pre)installed on each new VM? Is there such a possibility provided by Azure? Or should I install the Azure CLI with yum for each VM within my script? Any information or ideas is highly appreciated, thank you.
You need to install the Azure CLI yourself. See the steps here. You can install it following the steps one by one, or put the commands inside a script and execute the script in the VM extension or cloud-init in the creation time.
So I made the mistake of trying to capture an image of my VM without first running sysprep /generalize on it. Now I have a VM I can't start and an image I can't create a VM from.
Is there any way I can restore my original VM so I can create a valid image from it?
I saw this blog post https://learn.microsoft.com/en-us/archive/blogs/shwetanayak/captured-the-virtual-machine-didnt-intend-to-generalize-it-now-what that seems to imply that I can, but it's solution says to create a copy of a VHD using a snapshot. When I try to create the snapshot, nothing shows up in the Source Disk managed disks drop down.
I am using create_option as from_image to create new vm and passing the old vhd url in it but it is not successfully provisioned.
What steps i need to follow to make it work ?
My vm is in azure from whose os disk i want to create new vms.
You will want to sysprep and generalize your VM and capture an image to use to deploy new VMs.
Follow the documentation located here: https://learn.microsoft.com/en-us/azure/virtual-machines/windows/capture-image-resource
I have an Ubuntu Server 17.10 VM in vCenter that I exported using Export-VApp, then used Microsoft's Virtual Machine Converter to create a VHD. Created an Azure RM Disk Image from that and spun up a VM, all of which seemed to go fine. My problem is that the New-AzureRMVM gets stuck in creating, and when I go to the boot diagnostics from the screenshot it is stuck on a "Please unlock disk sda5_crypt:". First, from what I gather is there really no way to get console access to my VM so that I can enter this? It won't get past creating so connect is greyed out and I can't SSH into it. Is my only option here to go back to the VM on vCenter and migrate the entire partition to a new partition without disk encryption, then redeploy? Is there any sort of startup file Azure accepts that could input this for me?
I'm trying to use the azure command line to start a vm:
azure vm start myvmnamehere
But it's telling me:
No deployments were found
I'm guessing that I need to specify the location "West US"?
azure vm start is going to start a virtual machine that you've already created, within a specific region. To do that, you'd first need to call azure vm create. You would first create your vm from an image in the gallery (and within a dns name, xxxxx.cloudapp.net). To see the images available to you, try running azure vm image list.
Also: don't forget to add --ssh or --rdp so you can have remote access, when calling azure vm create.
Jeff Wilcox blogged about this in more detail, here.