VM Applications are a resource type in Azure Compute Gallery (formerly known as Shared Image Gallery) that simplifies management, sharing and global distribution of applications for your virtual machines.
Prerequisites
Before you get started, make sure you have the following:
You should have uploaded your application to a container in an Azure storage account. Your application can be stored in a block or page blob. If you choose to use a page blob, you need to byte align the files before you upload them. Here's a sample that will byte align your file:
Ensure the storage account has public level access or use an SAS URI with read privilege, as other restriction levels fail deployments. You can use Storage Explorer to quickly create a SAS URI if you don't already have one.
If you're using PowerShell, you need to be using version 3.11.0 of the Az.Storage module.
Go to the Azure portal, then search for and select Azure Compute Gallery.
Select the gallery you want to use from the list.
On the page for your gallery, select Add from the top of the page and then select VM application definition from the drop-down. The Create a VM application definition page opens.
In the Basics tab, enter a name for your application and choose whether the application is for VMs running Linux or Windows.
Select the Publishing options tab if you want to specify any of the following optional settings for your VM application definition:
A description of the VM application definition.
End of life date
Link to a Eula
URI of a privacy statement
URI for release notes
When you're done, select Review + create.
When validation completes, select Create to have the definition deployed.
Once the deployment is complete, select Go to resource.
On the page for the application, select Create a VM application version. The Create a VM Application Version page opens.
Enter a version number like 1.0.0.
Select the region where you've uploaded your application package.
Under Source application package, select Browse. Select the storage account, then the container where your package is located. Select the package from the list and then select Select when you're done. Alternatively, you can paste the SAS URI in this field if preferred.
Type in the Install script. You can also provide the Uninstall script and Update script. See the Overview for information on how to create the scripts.
If you have a default configuration file uploaded to a storage account, you can select it in Default configuration.
Select Exclude from latest if you don't want this version to appear as the latest version when you create a VM.
For End of life date, choose a date in the future to track when this version should be retired. It isn't deleted or removed automatically, it's only for your own tracking.
To replicate this version to other regions, select the Replication tab and add more regions and make changes to the number of replicas per region. The original region where your version was created must be in the list and can't be removed.
When you're done making changes, select Review + create at the bottom of the page.
When validation shows as passed, select Create to deploy your VM application version.
Now you can create a VM and deploy the VM application to it using the portal. Just create the VM as usual, and under the Advanced tab, choose Select a VM application to install.
Select the VM application from the list, and then select Save at the bottom of the page.
If you have more than one VM application to install, you can set the install order for each VM application back on the Advanced tab.
You can also deploy the VM application to currently running VMs. Select the Extensions + applications option under Settings in the left menu when viewing the VM details in the portal.
Choose VM applications and then select Add application to add your VM application.
Select the VM application from the list, and then select Save at the bottom of the page.
To show the VM application status, go to the Extensions + applications tab/settings and check the status of the VMAppExtension:
To show the VM application status for VMSS, go to the VMSS page, Instances, select one of them, then go to VMAppExtension:
VM applications require Azure CLI version 2.30.0 or later.
Create the VM application definition using az sig gallery-application create. In this example, we're creating a VM application definition named myApp for Linux-based VMs.
az sig gallery-application create \
--application-name myApp \
--gallery-name myGallery \
--resource-group myResourceGroup \
--os-type Linux \
--location "China East"
Create a VM application version using az sig gallery-application version create. Allowed characters for version are numbers and periods. Numbers must be within the range of a 32-bit integer. Format: MajorVersion.MinorVersion.Patch.
Replace the values of the parameters with your own.
az vmss get-instance-view --ids (az vmss list-instances -g myResourceGroup -n myVmss --query "[*].id" -o tsv) --query "[*].extensions[?name == 'VMAppExtension']"
Note
The above VMSS deployment status command does not list the instance ID with the result. To show the instance ID with the status of the extension in each instance, some additional scripting is required. Refer to the below VMSS CLI example that contains PowerShell syntax:
Create the VM application definition using New-AzGalleryApplication. In this example, we're creating a Linux app named myApp in the myGallery Azure Compute Gallery, in the myGallery resource group and I've given a short description of the VM application for my own use. Replace the values as needed.
Create a version of your application using New-AzGalleryApplicationVersion. Allowed characters for version are numbers and periods. Numbers must be within the range of a 32-bit integer. Format: MajorVersion.MinorVersion.Patch.
In this example, we're creating version number 1.0.0. Replace the values of the variables as needed.
To add the application to an existing VM, get the application version and use that to get the VM application version ID. Use the ID to add the application to the VM configuration.
A unique name for the VM Application within the gallery
Max length of 117 characters. Allowed characters are uppercase or lowercase letters, digits, hyphen(-), period (.), underscore (_). Names not allowed to end with period(.).
supportedOSType
Whether this is a Windows or Linux application
"Windows" or "Linux"
endOfLifeDate
A future end of life date for the application. Note this is for reference only, and isn't enforced.
Optional. The order in which the applications should be deployed. See below.
Validate integer
packageReferenceId
A reference the gallery application version
Valid application version reference
configurationReference
Optional. The full url of a storage blob containing the configuration for this deployment. This will override any value provided for defaultConfiguration earlier.
Valid storage blob reference
treatFailureAsDeploymentFailure
Optional. Provisioning status for VM App. When set to false, provisioning status will always show 'succeeded' regardless of app deployment failure.
True or False
The order field may be used to specify dependencies between applications. The rules for order are the following:
Case
Install Meaning
Failure Meaning
No order specified
Unordered applications are installed after ordered applications. There's no guarantee of installation order amongst the unordered applications.
Installation failures of other applications, be it ordered or unordered doesn’t affect the installation of unordered applications.
Duplicate order values
Application is installed in any order compared to other applications with the same order. All applications of the same order will be installed after those with lower orders and before those with higher orders.
If a previous application with a lower order failed to install, no applications with this order install. If any application with this order fails to install, no applications with a higher order install.
Increasing orders
Application will be installed after those with lower orders and before those with higher orders.
If a previous application with a lower order failed to install, this application won't install. If this application fails to install, no application with a higher order installs.
The response includes the full VM model. The following are the
relevant parts.
If the VM applications haven't yet been installed on the VM, the value will be empty.
To get the result of VM instance view:
GET
/subscriptions/\<**subscriptionId**\>/resourceGroups/\<**resourceGroupName**\>/providers/Microsoft.Compute/virtualMachines/\<**VMName**\>/instanceView?api-version=2019-03-01
The VM App status is in the status message of the result of the VM App extension in the instance view.
To get the status for a VMSS Application:
GET
/subscriptions/\<**subscriptionId**\>/resourceGroups/\<**resourceGroupName**\>/providers/Microsoft.Compute/ virtualMachineScaleSets/\<**VMSSName**\>/virtualMachines/<**instanceId**>/instanceView?api-version=2019-03-01