Skip to content

Commit 41918d6

Browse files
authored
Merge pull request #102238 from cynthn/46759
Daniel's public PR #46759
2 parents 1033856 + 2a5f09a commit 41918d6

File tree

1 file changed

+91
-35
lines changed

1 file changed

+91
-35
lines changed

articles/virtual-machines/linux/image-builder-json.md

Lines changed: 91 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
---
22
title: Create an Azure Image Builder template (preview)
33
description: Learn how to create a template to use with Azure Image Builder.
4-
author: cynthn
5-
ms.author: cynthn
6-
ms.date: 07/31/2019
4+
author: danis
5+
ms.author: danis
6+
ms.date: 01/23/2020
77
ms.topic: article
88
ms.service: virtual-machines-linux
99
manager: gwallace
@@ -22,11 +22,15 @@ This is the basic template format:
2222
"tags": {
2323
"<name": "<value>",
2424
"<name>": "<value>"
25-
},
25+
}
2626
"identity":{},
2727
"dependsOn": [],
2828
"properties": {
29-
"buildTimeoutInMinutes": <minutes>,
29+
"buildTimeoutInMinutes": <minutes>,
30+
"vmProfile":
31+
{
32+
"vmSize": "<vmSize>"
33+
},
3034
"build": {},
3135
"customize": {},
3236
"distribute": {}
@@ -59,6 +63,24 @@ The location is the region where the custom image will be created. For the Image
5963
```json
6064
"location": "<region>",
6165
```
66+
## vmProfile
67+
By default Image Builder will use a "Standard_D1_v2" build VM, you can override this, for example, if you want to customize an Image for a GPU VM, you need a GPU VM size. This is optional.
68+
69+
```json
70+
{
71+
"vmSize": "Standard_D1_v2"
72+
},
73+
```
74+
75+
## osDiskSizeGB
76+
77+
By default, Image Builder will not change the size of the image, it will use the size from the source image. You can adjust the size of the OS Disk (Win and Linux), note, do not go too small than the minimum required space required for the OS. This is optional, and a value of 0 means leave the same size as the source image. This is optional.
78+
79+
```json
80+
{
81+
"osDiskSizeGB": 100
82+
},
83+
```
6284

6385
## Tags
6486

@@ -132,13 +154,7 @@ In the list of **Installers and Images for Red Hat Enterprise Linux Server**, yo
132154
> The access tokens of the links are refreshed at frequent intervals, so every time you want to submit a template, you must check if the RH link address has changed.
133155
134156
### PlatformImage source
135-
Azure Image Builder supports the following Azure Marketplace images:
136-
* Ubuntu 18.04
137-
* Ubuntu 16.04
138-
* RHEL 7.6
139-
* CentOS 7.6
140-
* Windows 2016
141-
* Windows 2019
157+
Azure Image Builder supports Windows Server and client, and Linux Azure Marketplace images, see [here](https://docs.microsoft.com/azure/virtual-machines/windows/image-builder-overview#os-support) for the full list.
142158

143159
```json
144160
"source": {
@@ -217,7 +233,8 @@ When using `customize`:
217233
{
218234
"type": "Shell",
219235
"name": "<name>",
220-
"scriptUri": "<path to script>"
236+
"scriptUri": "<path to script>",
237+
"sha256Checksum": "<sha256 checksum>"
221238
},
222239
{
223240
"type": "Shell",
@@ -243,7 +260,8 @@ The shell customizer supports running shell scripts, these must be publicly acce
243260
{
244261
"type": "Shell",
245262
"name": "<name>",
246-
"scriptUri": "<link to script>"
263+
"scriptUri": "<link to script>",
264+
"sha256Checksum": "<sha256 checksum>"
247265
},
248266
],
249267
"customize": [
@@ -263,7 +281,12 @@ Customize properties:
263281
- **name** - name for tracking the customization
264282
- **scriptUri** - URI to the location of the file
265283
- **inline** - array of shell commands, separated by commas.
266-
284+
- **sha256Checksum** - Value of sha256 checksum of the file, you generate this locally, and then Image Builder will checksum and validate.
285+
* To generate the sha256Checksum, using a terminal on Mac/Linux run: `sha256sum <fileName>`
286+
287+
288+
For commands to run with super user privileges, they must be prefixed with `sudo`.
289+
267290
> [!NOTE]
268291
> When running the shell customizer with RHEL ISO source, you need to ensure your first customization shell handles registering with a Red Hat entitlement server before any customization occurs. Once customization is complete, the script should unregister with the entitlement server.
269292
@@ -272,12 +295,15 @@ The Restart customizer allows you to restart a Windows VM and wait for it come b
272295

273296
```json
274297
"customize": [
275-
{
276-
"type": "WindowsRestart",
277-
"restartCommand": "shutdown /r /f /t 0 /c",
278-
"restartCheckCommand": "echo Azure-Image-Builder-Restarted-the-VM > buildArtifacts/azureImageBuilderRestart.txt",
279-
"restartTimeout": "5m"
280-
}],
298+
299+
{
300+
"type": "WindowsRestart",
301+
"restartCommand": "shutdown /r /f /t 0 /c",
302+
"restartCheckCommand": "echo Azure-Image-Builder-Restarted-the-VM > c:\\buildArtifacts\\azureImageBuilderRestart.txt",
303+
"restartTimeout": "5m"
304+
}
305+
306+
],
281307
```
282308

283309
OS Support: Windows
@@ -297,13 +323,16 @@ The shell customizer supports running PowerShell scripts and inline command, the
297323
{
298324
"type": "PowerShell",
299325
"name": "<name>",
300-
"scriptUri": "<path to script>"
326+
"scriptUri": "<path to script>",
327+
"runElevated": "<true false>",
328+
"sha256Checksum": "<sha256 checksum>"
301329
},
302330
{
303331
"type": "PowerShell",
304332
"name": "<name>",
305333
"inline": "<PowerShell syntax to run>",
306-
"valid_exit_codes": "<exit code>"
334+
"valid_exit_codes": "<exit code>",
335+
"runElevated": "<true or false>"
307336
}
308337
],
309338
```
@@ -316,6 +345,10 @@ Customize properties:
316345
- **scriptUri** - URI to the location of the PowerShell script file.
317346
- **inline** – Inline commands to be run, separated by commas.
318347
- **valid_exit_codes** – Optional, valid codes that can be returned from the script/inline command, this will avoid reported failure of the script/inline command.
348+
- **runElevated** – Optional, boolean, support for running commands and scripts with elevated permissions.
349+
- **sha256Checksum** - Value of sha256 checksum of the file, you generate this locally, and then Image Builder will checksum and validate.
350+
* To generate the sha256Checksum, using a PowerShell on Windows [Get-Hash](https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/get-filehash?view=powershell-6)
351+
319352

320353
### File customizer
321354

@@ -327,7 +360,8 @@ The File customizer lets image builder download a file from a GitHub or Azure st
327360
"type": "File",
328361
"name": "<name>",
329362
"sourceUri": "<source location>",
330-
"destination": "<destination>"
363+
"destination": "<destination>",
364+
"sha256Checksum": "<sha256 checksum>"
331365
}
332366
]
333367
```
@@ -395,8 +429,39 @@ Azure Image Builder supports three distribution targets:
395429

396430
You can distribute an image to both of the target types in the same configuration, please see [examples](https://github.com/danielsollondon/azvmimagebuilder/blob/7f3d8c01eb3bf960d8b6df20ecd5c244988d13b6/armTemplates/azplatform_image_deploy_sigmdi.json#L80).
397431

398-
Because you can have more than one target to distribute to, Image Builder maintains a state for every distribution target that can be accessed by querying the `runOutputName`. The `runOutputName` is an object you can query post distribution for information about that distribution. For example, you can query the location of the VHD, or regions where the image version was replicated to. This is a property of every distribution target. The `runOutputName` must be unique to each distribution target.
399-
432+
Because you can have more than one target to distribute to, Image Builder maintains a state for every distribution target that can be accessed by querying the `runOutputName`. The `runOutputName` is an object you can query post distribution for information about that distribution. For example, you can query the location of the VHD, or regions where the image version was replicated to, or SIG Image version created. This is a property of every distribution target. The `runOutputName` must be unique to each distribution target. Here is an example, this is querying a Shared Image Gallery distribution:
433+
434+
```bash
435+
subscriptionID=<subcriptionID>
436+
imageResourceGroup=<resourceGroup of image template>
437+
runOutputName=<runOutputName>
438+
439+
az resource show \
440+
--ids "/subscriptions/$subscriptionID/resourcegroups/$imageResourceGroup/providers/Microsoft.VirtualMachineImages/imageTemplates/ImageTemplateLinuxRHEL77/runOutputs/$runOutputName" \
441+
--api-version=2019-05-01-preview
442+
```
443+
444+
Output:
445+
```json
446+
{
447+
"id": "/subscriptions/xxxxxx/resourcegroups/rheltest/providers/Microsoft.VirtualMachineImages/imageTemplates/ImageTemplateLinuxRHEL77/runOutputs/rhel77",
448+
"identity": null,
449+
"kind": null,
450+
"location": null,
451+
"managedBy": null,
452+
"name": "rhel77",
453+
"plan": null,
454+
"properties": {
455+
"artifactId": "/subscriptions/xxxxxx/resourceGroups/aibDevOpsImg/providers/Microsoft.Compute/galleries/devOpsSIG/images/rhel/versions/0.24105.52755",
456+
"provisioningState": "Succeeded"
457+
},
458+
"resourceGroup": "rheltest",
459+
"sku": null,
460+
"tags": null,
461+
"type": "Microsoft.VirtualMachineImages/imageTemplates/runOutputs"
462+
}
463+
```
464+
400465
### Distribute: managedImage
401466

402467
The image output will be a managed image resource.
@@ -502,12 +567,3 @@ az resource show \
502567

503568
There are sample .json files for different scenarios in the [Azure Image Builder GitHub](https://github.com/danielsollondon/azvmimagebuilder).
504569

505-
506-
507-
508-
509-
510-
511-
512-
513-

0 commit comments

Comments
 (0)