Azure has Template Specs which lets you create a self service infrastructure as code model for your end users. You can use RBAC and they can deploy versioned templates. Microsoft introduced VM applications which lets your end users do something very similar to template specs, but with applications installed inside your VM. Let’s look at a quick demo and some things to watch out for.
Assuming you have an Azure compute gallery deployed, you need to create an application then a version of that application. I pasted a snippet below to get us started.
$applicationName = 'visualStudioCode-linux' New-AzGalleryApplication ` -ResourceGroupName $rgName ` -GalleryName $galleryName ` -Location $location ` -Name $applicationName ` -SupportedOSType Linux ` -Description "Installs Visual Studio Code on Linux." $version = '1.0.0' New-AzGalleryApplicationVersion ` -ResourceGroupName $rgName ` -GalleryName $galleryName ` -GalleryApplicationName $applicationName ` -Name $version ` -PackageFileLink $sasVscode ` -Location $location ` -Install "mv visualStudioCode-linux vscode.sh && bash vscode.sh install" ` -Remove "bash vscode.sh remove" ` -Update "mv visualStudioCode-linux vscode.sh && bash vscode.sh update"
The cmdlet I want to focus on is New-AzGalleryApplicationVersion. The parameter PackageFileLink is required. Not only is it required, it must be a readable storage page blob aka you cannot use a raw github link to a file. I tried using a public repo for an install script, but when running this cmdlet, it just hangs. Now, I will get to a workaround on that, but let’s continue. The Install and Remove parameter are required, but update is optional. With that, I thought a simple framework can be used.
if [ $1 == "install" ]; then echo "Installing..."; <code> elif [ $1 == "remove" ]; then echo "Removing..."; <code> elif [ $1 == "update" ] then echo "Updating..."; <code> else echo "Incorrect argument passed. Please use install, remove or update"; fi
Now I can easily just call an argument for install, remove and update. Reading about VS Code, we can use snap to handle our application installation.
if [ $1 == "install" ]; then echo "Installing..."; sudo snap install --classic code elif [ $1 == "remove" ]; then echo "Removing..."; sudo snap remove code elif [ $1 == "update" ] then echo "Updating..."; sudo snap refresh --classic code else echo "Incorrect argument passed. Please use install, remove or update"; fi
Now, going back where I said there is a workaround on referencing a public repo. This is partially true. What you can do is reference a valid url dummy file in the PageFileLink parameter then execute your commands directly in the Install, Update and Remove parameter.
-Install "apt-get update && apt-get install ubuntu-gnome-desktop xrdp gnome-shell-extensions -y && reboot" ` -Remove "apt-get --purge remove ubuntu-gnome-desktop xrdp gnome-shell-extensions -y && reboot"
A couple of other things to note. Once a user starts an application install, it executes fast, but the status could use some work. If I am an end user in the portal and click install for a published application, I have to click back on the extension to see the status. The status isn’t in the VM application tab. Also, development is some what painful. If the install, update or remove section fails, it seems to go in this endless loop and a giant pain to make it stop. I couldn’t figure it out. The documentation states to uninstall the extension, which I did, but it still keeps it on the VM. It is still in preview, so I can’t complain too much. Lastly, unlike template spec’s which lets you select a spec in another subscription in the portal, this does not exist for VM Apps. You need to make sure a compute gallery is in the subscription, then it will show for the end user. This limitation does not exist when using AZ Cli, Rest or AZ Powershell, as long as you have the correct permissions to talk with the compute gallery in another subscription.
I think VM Apps has a lot of potential to make the end user experience better. Think of apps typically installed for developers to test with. We can now ensure approved and validated applications are installed which I think it is a great win!
2 thoughts on “Azure VM Applications”
Great article Jimmy,
Trying to see the benefit of this vs something like DSC or Ansible. I think the premise is to have an application gallery maybe? But not sure how useful this would be. Honestly after a quick read through it, DSC seems like it would be a better approach to maintaining specific application versions across the fleet.
From a development perspective, I would think DevOps pipelines or Github Actions might be a better solution to this particular problem.
Hey Jeff, I think it is more of a self service portal the user controls. They can deploy whatever they want, upgrade or uninstall. I view it as an additional option they they could use vs other methods available.
LikeLiked by 1 person