This article talks about how to monitor, update, and delete the published VM Application and the deployed VM application resource on Azure Virtual Machine (VM) or Virtual Machine Scale Sets.
To view the properties of a published VM Application in the Azure portal:
- Sign in to the Azure portal.
- Search for Azure Compute Gallery.
- Select the gallery that contains your VM Application.
- Click the VM Application Name you want to view.
- The Overview/Properties blade displays information about the VM Application.
- The Overview/Versions blade displays all published versions and its basic properties like Target Regions, Provisioning state, and Replication state.
- Select a specific version to view all its details.
View the properties of a published VM Application or a specific version using the REST API:
Get VM Application details:
GET
https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}?api-version=2024-03-03
Sample response:
{
"id": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}",
"name": "{galleryApplicationName}",
"type": "Microsoft.Compute/galleries/applications",
"___location": "eastus",
"properties": {
"description": "Sample VM Application",
"provisioningState": "Succeeded",
"supportedOSTypes": ["Windows", "Linux"],
"endOfLifeDate": null,
"privacyStatementUri": "https://contoso.com/privacy",
"releaseNoteUri": "https://contoso.com/release-notes"
}
}
Get VM Application version details:
GET
https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}/versions/{galleryApplicationVersionName}?api-version=2024-03-03
Sample response:
{
"id": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}/versions/{galleryApplicationVersionName}",
"name": "{galleryApplicationVersionName}",
"type": "Microsoft.Compute/galleries/applications/versions",
"___location": "eastus",
"properties": {
"provisioningState": "Succeeded",
"publishingProfile": {
"source": {
"mediaLink": "https://storageaccount.blob.core.windows.net/vmapps/app.zip"
},
"replicaCount": 1,
"targetRegions": [
{
"name": "eastus",
"regionalReplicaCount": 1
}
]
},
"storageAccountType": "Standard_LRS"
}
}
The responses include properties such as name, ___location, provisioning state, description, and other metadata about the application or version.
Set variables:
rgName="myResourceGroup"
galleryName="myGallery"
appName="myVmApp"
versionName="1.0.0"
List all VM Applications in the gallery:
az sig gallery-application list \
--resource-group $rgName \
--gallery-name $galleryName \
-o table
Show a VM Application’s properties:
az sig gallery-application show \
--resource-group $rgName \
--gallery-name $galleryName \
--application-name $appName
List all versions for a VM Application:
az sig gallery-application version list \
--resource-group $rgName \
--gallery-name $galleryName \
--application-name $appName \
--query "[].{version:name, provisioningState:properties.provisioningState}" -o table
Show a specific VM Application version’s properties:
az sig gallery-application version show \
--resource-group $rgName \
--gallery-name $galleryName \
--application-name $appName \
--version-name $versionName
Use Azure PowerShell to view VM Application and version details in an Azure Compute Gallery.
Set variables:
$rgName = "myResourceGroup"
$galleryName = "myGallery"
$appName = "myVmApp"
$versionName = "1.0.0"
List all VM Applications in the gallery:
Get-AzGalleryApplication `
-ResourceGroupName $rgName `
-GalleryName $galleryName |
Select-Object Name, Location, ProvisioningState
Show a VM Application’s properties:
Get-AzGalleryApplication `
-ResourceGroupName $rgName `
-GalleryName $galleryName `
-Name $appName |
ConvertTo-Json -Depth 5
List all versions for a VM Application:
Get-AzGalleryApplicationVersion `
-ResourceGroupName $rgName `
-GalleryName $galleryName `
-GalleryApplicationName $appName |
Select-Object Name, @{n="ProvisioningState";e={$_.ProvisioningState}}
Show a specific VM Application version’s properties:
Get-AzGalleryApplicationVersion `
-ResourceGroupName $rgName `
-GalleryName $galleryName `
-GalleryApplicationName $appName `
-Name $versionName |
ConvertTo-Json -Depth 6
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 a scale set, go to the Azure portal Virtual Machine Scale Sets page. In the Instances section, select one of the scales sets listed, then go to VMAppExtension:
If the VM application isn't installed on the VM, the value is empty.
To get the result of VM instance view:
GET
/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{VMName}/instanceView?api-version=2024-03-03
The result looks like this:
{
...
"extensions" [
...
{
"name": "VMAppExtension",
"type": "Microsoft.CPlat.Core.VMApplicationManagerLinux",
"typeHandlerVersion": "1.0.9",
"statuses": [
{
"code": "ProvisioningState/succeeded",
"level": "Info",
"displayStatus": "Provisioning succeeded",
"message": "Enable succeeded: {\n \"CurrentState\": [\n {\n \"applicationName\": \"doNothingLinux\",\n \"version\": \"1.0.0\",\n \"result\": \"Install SUCCESS\"\n },\n {
\n \"applicationName\": \"badapplinux\",\n \"version\": \"1.0.0\",\n \"result\": \"Install FAILED Error executing command \u0027exit 1\u0027: command terminated with exit status=1\"\n }\n ],\n \"ActionsPerformed\": []\n}
"
}
]
}
...
]
}
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 the application on the Virtual Machine Scale Set:
GET
/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/ virtualMachineScaleSets/{VMSSName}/virtualMachines/{instanceId}/instanceView?api-version=2019-03-01
The output is similar to the VM example earlier.
To verify application deployment status on a VM, use 'az vm get-instance-view':
az vm get-instance-view -g myResourceGroup -n myVM --query "instanceView.extensions[?name == 'VMAppExtension']"
To verify application deployment status on Virtual Machine Scale Set, use 'az vmss get-instance-view':
az vmss get-instance-view --ids (az vmss list-instances -g myResourceGroup -n myVmss --query "[*].id" -o tsv) --query "[*].extensions[?name == 'VMAppExtension']"
Note
The previous Virtual Machine Scale Sets deployment status command doesn't list the instance ID with the result. To show the instance ID with the status of the extension in each instance, some more scripting is required. Refer to the following CLI example that contains PowerShell syntax:
$ids = az vmss list-instances -g myResourceGroup -n myVmss --query "[*].{id: id, instanceId: instanceId}" | ConvertFrom-Json
$ids | Foreach-Object {
$iid = $_.instanceId
Write-Output "instanceId: $iid"
az vmss get-instance-view --ids $_.id --query "extensions[?name == 'VMAppExtension']"
}
Verify the application succeeded:
$rgName = "myResourceGroup"
$vmName = "myVM"
$result = Get-AzVM -ResourceGroupName $rgName -VMName $vmName -Status
$result.Extensions | Where-Object {$_.Name -eq "VMAppExtension"} | ConvertTo-Json
To verify on your Virtual Machine Scale Set:
$rgName = "myResourceGroup"
$vmssName = "myVMss"
$result = Get-AzVmssVM -ResourceGroupName $rgName -VMScaleSetName $vmssName -InstanceView
$resultSummary = New-Object System.Collections.ArrayList
$result | ForEach-Object {
$res = @{ instanceId = $_.InstanceId; vmappStatus = $_.InstanceView.Extensions | Where-Object {$_.Name -eq "VMAppExtension"}}
$resultSummary.Add($res) | Out-Null
}
$resultSummary | ConvertTo-Json -Depth 5
- Open the Azure portal and go to the target virtual machine (VM) or Virtual Machine Scale Set.
- In Settings, select Extensions + applications, then select the VM Applications tab.
- Click uninstall button on the VM Application and Save.
- Track progress in Notifications or check Instance view for the VMAppExtension status.
To remove a VM application, update the applicationProfile
by clearing or excluding the target application.
Remove from a single VM:
PATCH
https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}?api-version=2024-03-03
Body
{
"properties": {
"applicationProfile": {
"galleryApplications": []
}
}
}
Remove from a VM scale set (model):
PATCH
https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmssName}?api-version=2024-03-03
Body
{
"properties": {
"virtualMachineProfile": {
"applicationProfile": {
"galleryApplications": []
}
}
}
}
Apply the change to existing VMSS instances (required when upgradePolicy.mode is Manual):
POST
https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmssName}/updateInstances?api-version=2024-03-03
Body
{
"instanceIds": ["0", "1"]
}
Remove from a single VM:
az vm update -g myResourceGroup -n myVM --set "properties.applicationProfile.galleryApplications=[]"
Remove from a VM scale set (model):
az vmss update -g myResourceGroup -n myVMss --set "virtualMachineProfile.applicationProfile.galleryApplications=[]"
Apply the change to existing VMSS instances (Manual upgrade policy):
az vmss update-instances -g myResourceGroup -n myVMss --instance-ids "*"
Remove from a single VM:
$rgName = "myResourceGroup"
$vmName = "myVM"
$vm = Get-AzVM -ResourceGroupName $rgName -Name $vmName
$vm.ApplicationProfile.GalleryApplications = @()
Update-AzVM -ResourceGroupName $rgName -VM $vm
Remove from a VM scale set (model) and apply to instances:
$rgName = "myResourceGroup"
$vmssName = "myVMss"
$vmss = Get-AzVmss -ResourceGroupName $rgName -VMScaleSetName $vmssName
$vmss.VirtualMachineProfile.ApplicationProfile.GalleryApplications = @()
Update-AzVmss -ResourceGroupName $rgName -VMScaleSetName $vmssName -VirtualMachineScaleSet $vmss
$instanceIds = (Get-AzVmssVM -ResourceGroupName $rgName -VMScaleSetName $vmssName).InstanceId
Update-AzVmssInstance -ResourceGroupName $rgName -VMScaleSetName $vmssName -InstanceId $instanceIds
To delete the VM Application resource, you need to first delete all its versions. Deleting the application version causes deletion of the application version resource from Azure Compute Gallery and all its replicas. The application blob in Storage Account used to create the application version is unaffected.
- Sign in to the Azure portal.
- Search for Azure Compute Gallery and open the target gallery.
- Select the VM application you want to remove.
- Select one or more versions, which you want to delete.
- To delete the VM application, first delete all the versions. Then click delete (on top of the blade).
- Monitor Notifications for completion. If deletion is blocked, remove any locks and ensure no VM or scale set references the application.
Delete the VM Application version:
DELETE
https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}/versions/{galleryApplicationVersionName}?api-version=2024-03-03
Delete the VM Application after all its versions are deleted:
DELETE
https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}?api-version=2024-03-03
Delete the VM Application version:
az sig gallery-application version delete --resource-group $rg-name --gallery-name $gallery-name --application-name $app-name --version-name $version-name
Delete the VM Application after all its versions are deleted:
az sig gallery-application delete --resource-group $rg-name --gallery-name $gallery-name --application-name $app-name
Delete the VM Application version:
Remove-AzGalleryApplicationVersion -ResourceGroupName $rgNmae -GalleryName $galleryName -GalleryApplicationName $galleryApplicationName -Name $name
Delete the VM Application after all its versions are deleted:
Remove-AzGalleryApplication -ResourceGroupName $rgNmae -GalleryName $galleryName -Name $name