Skip to content

Commit 192edfa

Browse files
authored
Merge pull request #80544 from cynthn/iblinux-updates
Image Builder - Daniel edits
2 parents 52b3ba3 + eb03a3e commit 192edfa

File tree

3 files changed

+59
-16
lines changed

3 files changed

+59
-16
lines changed

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

Lines changed: 51 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ This article shows you how you can create a customized Linux image using the Azu
1616
- Shell (inline) - runs specific commands. In this example, the inline commands include creating a directory and updating the OS.
1717
- File - copies a [file from GitHub](https://raw.githubusercontent.com/danielsollondon/azvmimagebuilder/master/quickquickstarts/exampleArtifacts/buildArtifacts/index.html) into a directory on the VM.
1818

19+
1920
We will be using a sample .json template to configure the image. The .json file we are using is here: [helloImageTemplateLinux.json](https://raw.githubusercontent.com/danielsollondon/azvmimagebuilder/master/quickquickstarts/0_Creating_a_Custom_Linux_Managed_Image/helloImageTemplateLinux.json).
2021

2122
> [!IMPORTANT]
@@ -52,7 +53,7 @@ az provider register -n Microsoft.VirtualMachineImages
5253
az provider register -n Microsoft.Storage
5354
```
5455

55-
## Create a resource group
56+
## Setup Example Variables
5657

5758
We will be using some pieces of information repeatedly, so we will create some variables to store that information.
5859

@@ -74,14 +75,17 @@ Create a variable for your subscription ID. You can get this using `az account s
7475
subscriptionID=<Your subscription ID>
7576
```
7677

77-
Create the resource group.
78+
## Create the resource group.
79+
This is used to store the image configuration template artifact and the image.
7880

7981
```azurecli-interactive
8082
az group create -n $imageResourceGroup -l $location
8183
```
8284

85+
## Set permissions on the resource group
86+
Give Image Builder 'contributor' permission to create the image in the resource group. Without the proper permissions, the image build will fail.
8387

84-
Give Image Builder permission to create resources in that resource group. The `--assignee` value is the app registration ID for the Image Builder service.
88+
The `--assignee` value is the app registration ID for the Image Builder service.
8589

8690
```azurecli-interactive
8791
az role assignment create \
@@ -90,9 +94,9 @@ az role assignment create \
9094
--scope /subscriptions/$subscriptionID/resourceGroups/$imageResourceGroup
9195
```
9296

93-
## Download the .json example
97+
## Download the template example
9498

95-
Download the example .json file and configure it with the variables you created.
99+
A parameterized sample image configuration template has been created for you to use. Download the sample .json file and configure it with the variables you set earlier.
96100

97101
```azurecli-interactive
98102
curl https://raw.githubusercontent.com/danielsollondon/azvmimagebuilder/master/quickquickstarts/0_Creating_a_Custom_Linux_Managed_Image/helloImageTemplateLinux.json -o helloImageTemplateLinux.json
@@ -104,7 +108,19 @@ sed -i -e "s/<imageName>/$imageName/g" helloImageTemplateLinux.json
104108
sed -i -e "s/<runOutputName>/$runOutputName/g" helloImageTemplateLinux.json
105109
```
106110

107-
## Create the image
111+
You can modify this example .json as needed. For example, you can increase the value of `buildTimeoutInMinutes` to allow for longer running builds. You can edit the file in Cloud Shell using `vi`.
112+
113+
```azurecli-interactive
114+
vi helloImageTemplateLinux.json
115+
```
116+
117+
> [!NOTE]
118+
> For source image, you must always [specify a version](https://github.com/danielsollondon/azvmimagebuilder/blob/master/troubleshootingaib.md#image-version-failure), you cannot use `latest`.
119+
>
120+
> If you add or change the resource group where the image is being distributed, you need to make sure the [permissions are set for the resource group](#set-permissions-on-the-resource-group).
121+
122+
123+
## Submit the image configuration
108124
Submit the image configuration to the VM Image Builder service
109125

110126
```azurecli-interactive
@@ -116,8 +132,27 @@ az resource create \
116132
-n helloImageTemplateLinux01
117133
```
118134

135+
If it completes successfully, it will return a success message, and create an image builder configuration template artifact in the $imageResourceGroup. You can see the resource group in the portal if you enable 'Show hidden types'.
136+
137+
Also, in the background, Image Builder creates a staging resource group in your subcription. Image Builder uses the staging resource group for the image build. The name of the resource group will be in this format: `IT_<DestinationResourceGroup>_<TemplateName>`.
138+
139+
> [!IMPORTANT]
140+
> Do not delete the staging resource group directly. If you delete the image template artifact, it will automatically delete the staging resource group. For more information, see the [Clean up](#clean-up) section at the end of this article.
141+
142+
If the service reports a failure during the image configuration template submission, see the [troubleshooting](https://github.com/danielsollondon/azvmimagebuilder/blob/master/troubleshootingaib.md#template-submission-errors--troubleshooting) steps. You will also need to delete the template before you retry submitting the build. To delete the template:
143+
144+
```azurecli-interactive
145+
az resource delete \
146+
--resource-group $imageResourceGroup \
147+
--resource-type Microsoft.VirtualMachineImages/imageTemplates \
148+
-n helloImageTemplateLinux01
149+
```
150+
151+
## Start the image build
152+
119153
Start the image build.
120154

155+
121156
```azurecli-interactive
122157
az resource invoke-action \
123158
--resource-group $imageResourceGroup \
@@ -126,7 +161,9 @@ az resource invoke-action \
126161
--action Run
127162
```
128163

129-
Wait until the build is complete. This can take about 15 minutes.
164+
Wait until the build is complete, for this example, it can take 10-15 minutes.
165+
166+
If you encounter any errors, please review these [troubleshooting](https://github.com/danielsollondon/azvmimagebuilder/blob/master/troubleshootingaib.md#image-build-errors--troubleshooting) steps.
130167

131168

132169
## Create the VM
@@ -174,14 +211,20 @@ For more detailed information about this .json file, see [Image builder template
174211

175212
## Clean up
176213

177-
When you are done, delete the resources.
214+
When you are done, you can delete the resources.
215+
216+
Delete the image builder template.
178217

179218
```azurecli-interactive
180219
az resource delete \
181220
--resource-group $imageResourceGroup \
182221
--resource-type Microsoft.VirtualMachineImages/imageTemplates \
183222
-n helloImageTemplateLinux01
223+
```
224+
225+
Delete the image resource group.
184226

227+
```bash
185228
az group delete -n $imageResourceGroup
186229
```
187230

articles/virtual-machines/linux/toc.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -274,13 +274,13 @@
274274
items:
275275
- name: Overview
276276
href: image-builder-overview.md
277-
- name: Use CLI
277+
- name: Use Azure CLI
278278
href: image-builder.md
279279
- name: Template reference
280280
href: image-builder-json.md
281-
- name: Use with galleries
281+
- name: Build for image galleries
282282
href: image-builder-gallery.md
283-
- name: Update an image version
283+
- name: Update an existing image
284284
href: image-builder-gallery-update-image-version.md
285285
- name: Troubleshoot
286286
href: https://github.com/danielsollondon/azvmimagebuilder/blob/master/troubleshootingaib.md

articles/virtual-machines/windows/toc.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -267,17 +267,17 @@
267267
items:
268268
- name: Overview
269269
href: ../linux/image-builder-overview.md?toc=%2fazure%2fvirtual-machines%2fwindows%2ftoc.json
270-
- name: Use CLI
270+
- name: Use Azure CLI
271271
href: image-builder.md
272-
- name: Use with galleries
272+
- name: Build for image galleries
273273
href: image-builder-gallery.md
274-
- name: Update an image version
274+
- name: Update an existing image
275275
href: image-builder-gallery-update-image-version.md
276-
- name: Use scripts in Azure Storage
276+
- name: Storing scripts
277277
href: ../linux/image-builder-user-assigned-identity.md?toc=%2fazure%2fvirtual-machines%2fwindows%2ftoc.json
278278
- name: Template reference
279279
href: ../linux/image-builder-json.md?toc=%2fazure%2fvirtual-machines%2fwindows%2ftoc.json
280-
- name: Troubleshoot
280+
- name: Troubleshoot
281281
href: https://github.com/danielsollondon/azvmimagebuilder/blob/master/troubleshootingaib.md
282282
- name: Find and use images
283283
href: cli-ps-findimage.md

0 commit comments

Comments
 (0)