With the introduction of Dv3 and Ev3 VMs in Microsoft Azure, it became possible to run nested virtualization on Azure. Since I’ve got Azure Stack on the brain these days, my immediate thought was, “I wonder if I can run Azure Stack on Azure?” (cue Inception music). Not only was the answer yes, but others had already started the process for me. Following in the footsteps of Daniel Neumann and Florent Appointaire, I was able to bet the process running. One of the engineers at Microsoft took some of that work, added their special sauce and rolled out a GitHub repo that helps you through the process. I have forked that repo, and started adding some automation myself.
If you are planning to add Linux Images to your Azure Stack deployment, first I would recommend reading through the documentation on the Azure Stack pages for Adding a VM Image and Using Custom Linux Images. From there you can get the base images and the process for adding the images to Azure Stack. What they don’t include is the Azure Cloud information for the various images, and if you would like to be able to use a JSON template against both Azure and Azure Stack without changing the image information, then you will want the publisher, offer, sku, and version to match. In this post I will walk through the basics of adding one Linux image, how to get the necessary information from Azure Cloud, and the current information for the images you may want to run.
First off, let me quell your anticipation. I got it working! It was not as straightforward as I might like, but it will work. If you haven’t already read post three, I would recommend doing so. The long and short of it is that the build task Azure Resource Group deployment in TFS doesn’t understand the Azure Stack environment. It doesn’t know how to talk to it, so any build task is going to fail. One of the engineers at Microsoft suggested I use a PowerShell task to deploy instead, which I did. That was not as simple as I would have liked, but here is what I had to do. Continue reading “CICD Pipeline with Azure Stack – Part 4”
As I mentioned in my previous post, I was “ready” to deploy my TFS deploy template to Azure Stack. And as predicted, the universe laughed at my funny plans. The deployment failed due to a required Windows Update on the target image. I didn’t run into this on Azure b/c the Windows Server 2012R2 image on Azure is more up to date than the one that ships with Azure Stack. At this point I could have just installed TFS and Visual Studio manually, but no I refuse to give up my dreams of an automated future. I spent the next week creating a PowerShell script that will install all available, required Windows Updates, and then reboot and repeat until there are no updates left. Then I ran that script against a Windows Server 2012R2 VM in Azure Stack, and used that updated VM to create an updated VM Image. You can read all about that adventure here. Let’s just say that the yak is well and truly shorn. Continue reading “CICD Pipeline with Azure Stack – Part 3”
If you’ve started playing with Azure Stack, you might notice that the Windows Server 2012R2 image is a little behind on its Windows patches. Before you do any heavy duty testing, you’re going to want to update the image with the latest patches. This is a multi-step process:
- Deploy an image to update
- Install all available Windows Updates (I’ve got a script for that!)
- Sysprep the machine to be a new image
- Locate the VHD file
- Update the image using the portal or PowerShell
I’m not going to walk you through deploying a VM in Azure Stack, but I will recommend that you use the A2 size. Installing the update should go a little faster on a system with more horsepower.
Using PowerShell to run Windows Update
You could manually update the VM with all the Windows Updates, but why do that when there’s PowerShell? I’m making use of the Windows Update PowerShell module available on the TechNet gallery. All you have to do is copy this script from my Gist to the target VM. Then run it. The script will download and import the module, install the available Windows Updates, and then create a scheduled task to run again on startup. It should keep running until there are no updates left. Fire away and come back in a few hours depending on your internet connection. It took an A2 VM about four hours to patch when I last ran this. Glad I didn’t have to babysit it!
Now that your VM is properly patched up, it needs to be prepared for use as an image. Fortunately, all the necessary settings and VM agent are already installed. From an administrative command prompt run sysprep:
The VM will shutdown when sysprep is complete. Make sure that you go into the portal and stop it from there, so it is deallocated properly.
The VHD location for the VM will vary depending on the storage account you used. From within the portal, go to the VM’s Disks
Select the OS disk and then copy the blob URI by clicking on the neat little clipboard icon. Paste that value into notepad or something similar.
Go into the storage account that was used to store the VHD. The blob properties of the VHD need to allow anonymous access. Select the Blob portion of the storage account, and then select the container which houses the vhd (usually vhds). Change the Access policy to Access type to Blob.
Now we’re going to add a new version of the Windows 2012R2 image. In the portal select Resource Providers
Select the Compute RP and then click on the VM Images on the far right
Click on the 2012-R2-Datacenter image and copy all the values to notepad
Now click on the Add button and use the previous values to fill out the fields. Be sure to increment the Version number in. In my case I went from 1.0.0 to 1.1.0.
Now click the Create button and wait. Once the creation process is complete, you will have a fully patched Windows Server 2012R2 image to use for your Azure Stack deployments. My creation time was about an hour, so don’t be surprised when it doesn’t create immediately.
You might wonder what happens with the existing Gallery Item that was using the version 1.0.0 template. Good question! The templates for the marketplace are unsurprisingly stored in a storage account in the System.Gallery Resource Group. If you dig down into the storage account you will find the blob container with the marketplace item here: dev20151001-microsoft-windowsazure-gallery/MicrosoftWindowsServer.WindowsServer-2012-R2-Datacenter.1.0.0
The template that controls deployment is called CreateUIDefinition.json. And that file doesn’t reference an actual version of the template. So despite the fact that the Gallery Item description claims that it uses the 1.0.0 version, it should use the latest version (1.1.0 in my case). I created a new VM to test, and as you can see, no Windows Updates were available.
PS – You can also add an image using PowerShell. If you’d like to know more about the process, then check here and use the same values you would have in the portal.
Here’s the full PowerShell script if you’re interested: