Create and deploy VM Applications

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:

This article assumes you already have an Azure Compute Gallery. If you don't already have a gallery, create one first. To learn more, see Create a gallery for storing and sharing resources.

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:

$inputFile = <the file you want to pad>

$fileInfo = Get-Item -Path $inputFile

$remainder = $fileInfo.Length % 512

if ($remainder -ne 0){

    $difference = 512 - $remainder

    $bytesToPad = [System.Byte[]]::CreateInstance([System.Byte], $difference)

    Add-Content -Path $inputFile -Value $bytesToPad -Encoding Byte
    }

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.

To learn more about the installation mechanism, see the command interpreter.

Create the VM application

Choose an option below for creating your VM application definition and version:

  1. Go to the Azure portal, then search for and select Azure Compute Gallery.
  2. Select the gallery you want to use from the list.
  3. 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.
  4. In the Basics tab, enter a name for your application and choose whether the application is for VMs running Linux or Windows.
  5. 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
  6. When you're done, select Review + create.
  7. When validation completes, select Create to have the definition deployed.
  8. Once the deployment is complete, select Go to resource.
  9. On the page for the application, select Create a VM application version. The Create a VM Application Version page opens.
  10. Enter a version number like 1.0.0.
  11. Select the region where you've uploaded your application package.
  12. 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.
  13. 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.
  14. If you have a default configuration file uploaded to a storage account, you can select it in Default configuration.
  15. Select Exclude from latest if you don't want this version to appear as the latest version when you create a VM.
  16. 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.
  17. 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.
  18. When you're done making changes, select Review + create at the bottom of the page.
  19. 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.

Screenshot of the Advanced tab where you can choose to install a VM application.

Select the VM application from the list, and then select Save at the bottom of the page.

Screenshot showing selecting a VM application to install on the VM.

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.

Screenshot showing selecting a VM application to install on a currently running VM.

Select the VM application from the list, and then select Save at the bottom of the page.

Screenshot showing selecting a VM application to install on the VM.

To show the VM application status, go to the Extensions + applications tab/settings and check the status of the VMAppExtension:

Screenshot showing VM application status.

To show the VM application status for VMSS, go to the VMSS page, Instances, select one of them, then go to VMAppExtension:

Screenshot showing VMSS application status.

Next steps

Learn more about VM applications.