DevTest labs in
Azure is a beast of its own. VMs in the Microsoft cloud are the fundament of the computing capability, yet they are somehow treated differently when under the
DevTest labs hood. And there are perhaps about a zillion (good) reasons to be
like that. Yet imagine a situation where you have a stand alone VM that is
specked with loads of good stuff and you just do not want to go through all
that process of building it from scratch on top of a base image in a DevTest
labs machine. In fact you want all the juice available right in the lab, in a single
click of a button please!
And this is
ufortunately not supported in an easy and lean manner through using Portal,PowerShell
or CLI compared to many other offerings in Azure. All the articles about VMs
and DevTest labs talk about either stand alone or as part of a lab - as if they
are never to be mixed together, a sort of some digital cloud anatema if you
wish! Yet both VM types are based on the very same technology. So is it really
that impossible to move a stand alone VM under a DevTest lab?
The answer is no, it
is far from impossible, though it is a bit more demanding. If one follows the
documentation slavishly one will unfortunately get nowhere with such a task.
However if one starts to connect the few vague red dots it suddenly becomes apparent
that it is actually doable and with all the available tooling indeed.
What I am about to
explain below is a way to create a custom DevTest lab image from an existing
stand alone VM with a single disk. I personally think that
there is no point of moving a single image to a DevTest lab as there is little
upside of all this. If that is the case, you'd better stick to the stand alone
VM. With a custom lab image you have the ability to quickly provision multiple
VMs from the same source taking all the management benefits of what DevTest
labs can pull out of its sleeves.
As for the case with data disks I will explore this in a later post.
As for the case with data disks I will explore this in a later post.
Here is the
instruction. But before we set off one important prerequisite - all the resources involved below are within the same subscription!
- First follow the isntructions on generalizing the VM as discribed here. If you do it with CLI/PowerShell just make sure you do not run the last commands for creating a new image as per the examples in the article. If you do so you will end up with an image outside the DevTest lab premises.
- Once this is done the VM will
be stopped, dealocated and marked as generalized. Now here is where the
trick comes - you need to copy the VMs disk underlying VHD to the default
storage account of the DevTest lab. That makes sense, right? Sure! But
where is the path to the VHD? Properties of the VM you may say? Or the
ones of the OS disk perhaps? Sorry Mack, these goodies are long gone! The
VHD path is well hidden primarily, I reckon, due to security reasons.
Which is a good thing for everybody, right? So how do we get hold of the
VHD then you may ask? There is an option in the stand alone VMs disk blade for
downloading the VHD. Select this option and you will be presented with a
text field and a Generate link button:
Please set the value for export time validity to a reasonably high value. Default is 3600 secs which is 1 hour. I suggest you roughly estimate 100GB/Hour and then calculate based on the disk's size. Add some 10-15 mins (600-900 secs) as a buffer too. Once the calculated time value has been keyed in click on the Generate URL button. This will render the link in the large grayed out field on the top of the view as show below:
Copy the URL. - Now it is time to figure out
the default storage account for your dev test lab. This one is pretty well
hidden too and it is nowhere to be found in the portal. Here comes in hand
our friend Azure CLI. Open the console in the portal and type the
following command:
az lab get --name '<your lab name>' -g '<your resource group name>' --query 'defaultStorageAccount'
- Navigate to the storage account from within the portal, or through CLI if you prefer and note down 2 things for it:
- The URL to the account
- One of the access keys from the properties view in the storage account blade.
- Now all is set up and we can start the data copy process. For this we shall be using the Azure CLI in the portal again. Type the following command:
- Well thats all it takes! Once the VHD file is uploaded to the DevTest labs container you simply follow the instructions on creating a custom lab image from a generalized VHD file that can be found here
- And finally - once the image is created the last thing that remains is to finally spin a VM instance or 2 from that Image. Detailed description to be found here
azcopy --source '<the download disk link from step 2>' --destination '<the link to the DevTest lab storage account blob container/yourimagename.vhd>' --dest-key '<the key for accessing the storage account>'
Obviously
for the last 2 steps above you can use Azure CLI instead.
Ingen kommentarer:
Legg inn en kommentar