Skip to content

Commit 03cfc72

Browse files
authored
Merge pull request #205406 from ericd-mst-github/erd-vm-applications-how-to
Erd vm applications how to
2 parents 5667376 + e7ceb1e commit 03cfc72

File tree

2 files changed

+63
-24
lines changed

2 files changed

+63
-24
lines changed

articles/virtual-machines/vm-applications-how-to.md

Lines changed: 47 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: Create and deploy VM application packages (preview)
2+
title: Create and deploy VM application packages
33
description: Learn how to create and deploy VM Applications using an Azure Compute Gallery.
44
ms.service: virtual-machines
55
ms.subservice: gallery
@@ -11,15 +11,13 @@ ms.custom:
1111

1212
---
1313

14-
# Create and deploy VM Applications (preview)
14+
# Create and deploy VM Applications
1515

1616
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.
1717

1818

1919
> [!IMPORTANT]
20-
> **VM applications in Azure Compute Gallery** are currently in public preview.
21-
> This preview version is provided without a service-level agreement, and we don't recommend it for production workloads. Certain features might not be supported or might have constrained capabilities.
22-
> For more information, see [Supplemental Terms of Use for Microsoft Azure Previews](https://azure.microsoft.com/support/legal/preview-supplemental-terms/).
20+
> Deploying **VM applications in Azure Compute Gallery** do not currently support using Azure policies.
2321
2422

2523
## Prerequisites
@@ -144,8 +142,36 @@ Set a VM application to an existing VM using [az vm application set](/cli/azure/
144142
az vm application set \
145143
--resource-group myResourceGroup \
146144
--name myVM \
147-
--app-version-ids /subscriptions/{subID}/resourceGroups/MyResourceGroup/providers/Microsoft.Compute/galleries/myGallery/applications/myApp/versions/1.0.0 \
145+
--app-version-ids /subscriptions/{subID}/resourceGroups/MyResourceGroup/providers/Microsoft.Compute/galleries/myGallery/applications/myApp/versions/1.0.0 \
146+
--treat-deployment-as-failure true
148147
```
148+
For setting multiple applications on a VM:
149+
150+
```azurecli-interactive
151+
az vm applicaction set \
152+
--resource-group myResourceGroup \
153+
--name myVM \
154+
--app-version-ids <appversionID1> <appversionID2> \
155+
--treat-deployment-as-failure true
156+
```
157+
To verify application VM deployment status:
158+
159+
```azurecli-interactive
160+
az vm get-instance-view -g myResourceGroup -n myVM --query "instanceView.extensions[?name == 'VMAppExtension']"
161+
```
162+
For verifying application VMSS deployment status:
163+
164+
```azurecli-interactive
165+
$ids = az vmss list-instances -g myResourceGroup -n $vmssName --query "[*].{id: id, instanceId: instanceId}" | ConvertFrom-Json
166+
$ids | Foreach-Object {
167+
$iid = $_.instanceId
168+
Write-Output "instanceId: $iid"
169+
az vmss get-instance-view --ids $_.id --query "extensions[?name == 'VMAppExtension']"
170+
}
171+
```
172+
> [!NOTE]
173+
> The VMSS deployment status contains PowerShell syntax. Refer to the 2nd [vm-extension-delete](/cli/azure/vm/extension#az-vm-extension-delete-examples) example as there is precedence for it.
174+
149175

150176
### [PowerShell](#tab/powershell)
151177

@@ -179,6 +205,7 @@ New-AzGalleryApplicationVersion `
179205
-GalleryApplicationName $applicationName `
180206
-Name $version `
181207
-PackageFileLink "https://<storage account name>.blob.core.windows.net/<container name>/<filename>" `
208+
-DefaultConfigFileLink "https://<storage account name>.blob.core.windows.net/<container name>/<filename>" `
182209
-Location "East US" `
183210
-Install "mv myApp .\myApp\myApp" `
184211
-Remove "rm .\myApp\myApp" `
@@ -194,20 +221,23 @@ $applicationName = "myApp"
194221
$vmName = "myVM"
195222
$vm = Get-AzVM -ResourceGroupName $rgname -Name $vmName
196223
$appversion = Get-AzGalleryApplicationVersion `
197-
-GalleryApplicationName $applicationname `
198-
-GalleryName $galleryname `
224+
-GalleryApplicationName $applicationName `
225+
-GalleryName $galleryName `
199226
-Name $version `
200-
-ResourceGroupName $rgname
227+
-ResourceGroupName $rgName
201228
$packageid = $appversion.Id
202229
$app = New-AzVmGalleryApplication -PackageReferenceId $packageid
203-
Add-AzVmGalleryApplication -VM $vm -GalleryApplication $app
204-
Update-AzVM -ResourceGroupName $rgname -VM $vm
230+
Add-AzVmGalleryApplication -VM $vm -GalleryApplication $app -TreatFailureAsDeploymentFailure true
231+
Update-AzVM -ResourceGroupName $rgName -VM $vm
205232
```
206233

207234
Verify the application succeeded:
208235

209236
```powershell-interactive
210-
Get-AzVM -ResourceGroupName $rgname -VMName $vmname -Status
237+
$rgName = "myResourceGroup"
238+
$vmName = "myVM"
239+
$result = Get-AzVM -ResourceGroupName $rgName -VMName $vmName -Status
240+
$result.Extensions | Where-Object {$_.Name -eq "VMAppExtension"} | ConvertTo-Json
211241
```
212242

213243
### [REST](#tab/rest2)
@@ -299,7 +329,8 @@ PUT
299329
{
300330
"order": 1,
301331
"packageReferenceId": "/subscriptions/{subscriptionId}/resourceGroups/<resource group>/providers/Microsoft.Compute/galleries/{gallery name}/applications/{application name}/versions/{version}",
302-
"configurationReference": "{path to configuration storage blob}"
332+
"configurationReference": "{path to configuration storage blob}",
333+
"treatFailureAsDeploymentFailure": false
303334
}
304335
]
305336
}
@@ -326,7 +357,8 @@ virtualMachineScaleSets/\<**VMSSName**\>?api-version=2019-03-01
326357
{
327358
"order": 1,
328359
"packageReferenceId": "/subscriptions/{subscriptionId}/resourceGroups/<resource group>/providers/Microsoft.Compute/galleries/{gallery name}/applications/{application name}/versions/{version}",
329-
"configurationReference": "{path to configuration storage blob}"
360+
"configurationReference": "{path to configuration storage blob}",
361+
"treatFailureAsDeploymentFailure": false
330362
}
331363
]
332364
}
@@ -344,6 +376,7 @@ virtualMachineScaleSets/\<**VMSSName**\>?api-version=2019-03-01
344376
| order | Optional. The order in which the applications should be deployed. See below. | Validate integer |
345377
| packageReferenceId | A reference the gallery application version | Valid application version reference |
346378
| 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 |
379+
| 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
347380

348381
The order field may be used to specify dependencies between applications. The rules for order are the following:
349382

articles/virtual-machines/vm-applications.md

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: Overview of VM Applications in the Azure Compute Gallery (preview)
2+
title: Overview of VM Applications in the Azure Compute Gallery
33
description: Learn more about VM application packages in an Azure Compute Gallery.
44
author: ericd-mst-github
55
ms.service: virtual-machines
@@ -13,14 +13,12 @@ ms.custom:
1313

1414
---
1515

16-
# VM Applications overview (preview)
16+
# VM Applications overview
1717

1818
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.
1919

2020
> [!IMPORTANT]
21-
> **VM applications in Azure Compute Gallery** are currently in public preview.
22-
> This preview version is provided without a service-level agreement, and we don't recommend it for production workloads. Certain features might not be supported or might have constrained capabilities.
23-
> For more information, see [Supplemental Terms of Use for Microsoft Azure Previews](https://azure.microsoft.com/support/legal/preview-supplemental-terms/).
21+
> Deploying **VM applications in Azure Compute Gallery** do not currently support using Azure policies.
2422
2523

2624
While you can create an image of a VM with apps pre-installed, you would need to update your image each time you have application changes. Separating your application installation from your VM images means there’s no need to publish a new image for every line of code change.
@@ -116,11 +114,11 @@ The install/update/remove commands should be written assuming the application pa
116114

117115
## File naming
118116

119-
During the preview, when the application file gets downloaded to the VM, the file name is the same as the name you use when you create the VM application. For example, if I name my VM application `myApp`, the file that will be downloaded to the VM will also be named `myApp`, regardless of what the file name is used in the storage account. If your VM application also has a configuration file, that file is the name of the application with `_config` appended. If `myApp` has a configuration file, it will be named `myApp_config`.
117+
When the application file gets downloaded to the VM, the file name is the same as the name you use when you create the VM application. For example, if I name my VM application `myApp`, the file that will be downloaded to the VM will also be named `myApp`, regardless of what the file name is used in the storage account. If your VM application also has a configuration file, that file is the name of the application with `_config` appended. If `myApp` has a configuration file, it will be named `myApp_config`.
120118

121119
For example, if I name my VM application `myApp` when I create it in the Gallery, but it's stored as `myApplication.exe` in the storage account, when it gets downloaded to the VM the file name will be `myApp`. My install string should start by renaming the file to be whatever it needs to be to run on the VM (like myApp.exe).
122120

123-
The install, update, and remove commands must be written with file naming in mind.
121+
The install, update, and remove commands must be written with file naming in mind. The `configFileName` is assigned to the config file for the VM and `packageFileName` is the name assigned downloaded package on the VM. For more information regarding these additional VM settings, refer to [UserArtifactSettings](https://docs.microsoft.com/rest/api/compute/gallery-application-versions/create-or-update?tabs=HTTP#userartifactsettings) in our API docs.
124122

125123
## Command interpreter
126124

@@ -249,11 +247,13 @@ Example remove command:
249247
```
250248
rmdir /S /Q C:\\myapp
251249
```
250+
## Treat failure as deployment failure
252251

252+
The VM application extension always returns a *success* regardless of whether any VM app failed while being installed/updated/removed. The VM Application extension will only report the extension status as failure when there's a problem with the extension or the underlying infrastructure. This is triggered by the "treat failure as deployment failure" flag which is set to `$false` by default and can be changed to `$true`. The failure flag can be configured in [PowerShell](/powershell/module/az.compute/add-azvmgalleryapplication#-treatfailureasdeploymentfailure) or [CLI](/cli/azure/vm/application#-treat-deployment-as-failure).
253253

254-
## Troubleshooting during preview
254+
## Troubleshooting VM Applications
255255

256-
During the preview, the VM application extension always returns a success regardless of whether any VM app failed while being installed/updated/removed. The VM Application extension will only report the extension status as failure when there's a problem with the extension or the underlying infrastructure. To know whether a particular VM application was successfully added to the VM instance, check the message of the VM Application extension.
256+
To know whether a particular VM application was successfully added to the VM instance, check the message of the VM Application extension.
257257

258258
To learn more about getting the status of VM extensions, see [Virtual machine extensions and features for Linux](extensions/features-linux.md#view-extension-status) and [Virtual machine extensions and features for Windows](extensions/features-windows.md#view-extension-status).
259259

@@ -266,7 +266,13 @@ Get-AzVM -name <VM name> -ResourceGroupName <resource group name> -Status | conv
266266
To get status of scale set extensions, use [Get-AzVMSS](/powershell/module/az.compute/get-azvmss):
267267

268268
```azurepowershell-interactive
269-
Get-AzVmss -name <VMSS name> -ResourceGroupName <resource group name> -Status | convertto-json -Depth 10
269+
$result = Get-AzVmssVM -ResourceGroupName $rgName -VMScaleSetName $vmssName -InstanceView
270+
$resultSummary = New-Object System.Collections.ArrayList
271+
$result | ForEach-Object {
272+
$res = @{ instanceId = $_.InstanceId; vmappStatus = $_.InstanceView.Extensions | Where-Object {$_.Name -eq "VMAppExtension"}}
273+
$resultSummary.Add($res) | Out-Null
274+
}
275+
$resultSummary | convertto-json -depth 5
270276
```
271277

272278
## Error messages

0 commit comments

Comments
 (0)