creating new VM in azure that uses existing vhd - azure

Is it possible to create a new VM (Azure RM) that uses an existing vhd disk (where everything is already set up) that is already on a storage account? In the new portal, I can't find any option for doing that. But can it be done by editing a template or by using PowerShell? Can anyone point me to any docs about this?

You can deploy an existing Vhd from both PowerShell and ARM Templates.
There are two methods of using an existing image. You can either directly attach that disk or you can use that disk as an image source.
If you look at the Create a Virtual Machine from a User Image template on Github. There is both a template and a PowerShell script.
Both of those are currently configured to make a copy of the Vhd and use that. If you want to directly attach your Vhd you would need to change this line (currently line 168) in the template
"createOption": "FromImage",
to
"createOption": "Attach",
You would do the same for the createoption of Add-AzureVMDataDisk

Yes you can create a Resource Manager VM from a VHD. It is possible through aRMT template. in Github there is a reference template, please edit and deploy that.
Thanks!
Sabha Mahadevan

Related

Is it possible to update the assigned Azure DSC configuration to a VM via ARM Template?

I need to change the Azure DSC configuration that has been previously assigned to a VM.
I'm trying to do this programatically because it's part of an automation I'm developing and because of this, I'm using ARM Templates.
However, redeploying the same VM DSC extension by ARM Template results in an error stating a VM can't have two of the same extensions, which sounds logical.
What I want to know if it's possible to, by ARM Template, "update" or "modify" the current extension with just one setting changed: The configuration name.
Is this possible?
Sure - you can update the existing VM extension by providing new configuration in your ARM template. As you have found out, you cannot use a different name for the extension - that would result in two VM extensions of the same type on the VM. Instead, you need to reuse the same name of the existing VM extension when performing the update.

How to prepare a windows vm so that it`s os disk can be used to provision other vms

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

using azure cli, vmss json template doesn't create vmss with datadisk

Context:
Trying to create VMs in Azure (cloud) using VMSS in ARM mode and using json templates.
Problem:
Creating a VMSS from an os image and datadisk image using Azure CLI and json template creates new VMSS but not the datadisk.
My success so far:
Successfully created VMs using CLI with both os and data disk from a custom image using json template. Also successfully created VMSS (Virtual Machine Scale Set) from a valid custom os image using CLI with json template.
My research for problem:
There isn't any sample on github for this scenario git hub templates. Microsoft azure site also have sample for os disk only and not creating a VMSS with data disk.
blkid comand doesn't show the data disk at all, meaning it was never created and mounted. My json template virtualMachineProfile->storageProfile declares a valid dataDisks object and I know it's works as it successfully creates VM (not VMSS) with data disk and also CLI doesn't return any error.
I know json based template is new and Microsoft is working on adding more features/functionalities so my questions is "Is there anything wrong that I am doing and is it that creating VMSS with data disk is not yet implemented in Azure ?"
Environment: Linux (Debian/RHEL)
Azure CLI : 0.9.13 (ARM mode)
Azure Api: 2015-06-15
Image: (CentOS 6.7)
Thanks for your help.
As per this blog post VMSS and data disks, it is not yet supported. Such a bummer..... Hopefully Microsoft will soon release this feature before selling VMSS too much.

Copy and install exe on azure vm via powershell

I'm trying to create an Azure VM and then copy an install file to the VM and then silently installing it. I have created a basic Azure Resource Group project, and can create and deploy the VM, but I can't figure out how to do everything from the powershell script.
It sounds like you could use a custom script extension to do what you want. In your ARM template, you can specify the url for a file and the command to run; Azure will handle getting the file onto your VM and running it based on your command. Here is an example from the Azure Quickstart Templates: https://github.com/Azure/azure-quickstart-templates/tree/master/windows-vm-custom-script
Hope this helps! :)

How to attach my uploaded vhd to a virtual machine in Azure?

I have uploaded successfully my 1TB vhd (not containing Windows files) to Azure storage.
Now I want to attach it as a second drive to my virtual machine but in the attach list I can find only the "attach an empty disk" option!
I used Add-AzureVhd to upload the vhd file:
Creating new page blob of size 999653638656...
I linked the storage resource in Cloud Service but the vhd is still not available to mount.
The container of the storage where I uploaded my vhd is the same with the one where C: drive of my VM is saved.
The container access is set to private.
Will it help if I change it to Public Blob or Public Container?
What else to try?
Thanks
Take a look at the PowerShell command Add-AzureDataDisk. This should be what you're looking for, as you can specify media location of the uploaded vhd.
Alternatively, in the portal, go to Virtual Machines and navigate to the Disks tab, where you can create a new disk:
At this point, you can navigate to your uploaded vhd:
After this is done, the new disk should become available for you to add to a Virtual Machine.
It should show the options to attach (Empty Disk and Existing Disk) as show in this link from Azure documentation.
Assuming the above not possible for what ever may be the reason, the alternative is
As the you already claim you are able to see the Attach Empty Disk; you can attach a 1 TB disk and download and put the blob contents there.
You wont be charged for the out-bandwidth as it is all internal
Make sure you used CSUpload and not just pushed the VHD to blob storage. See: http://msdn.microsoft.com/en-us/library/windowsazure/gg466228.aspx

Resources