Skip to content

Commit 8090169

Browse files
author
Jill Grant
authored
Merge pull request #234177 from divargas-msft/patch-1
[Doc-a-thon] Updating image-builder-devops-task.md
2 parents 893a3cf + af77203 commit 8090169

File tree

1 file changed

+33
-31
lines changed

1 file changed

+33
-31
lines changed

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

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: In this article, you use an Azure DevOps task to inject build artif
44
author: kof-f
55
ms.author: kofiforson
66
ms.reviewer: cynthn
7-
ms.date: 01/27/2021
7+
ms.date: 04/11/2023
88
ms.topic: article
99
ms.service: virtual-machines
1010
ms.subservice: image-builder
@@ -22,10 +22,9 @@ In this article, you learn how to use an Azure DevOps task to inject build artif
2222

2323
At this time, there are two Azure VM Image Builder DevOps tasks:
2424

25-
* [*Stable* VM Image Builder task](https://marketplace.visualstudio.com/items?itemName=AzureImageBuilder.devOps-task-for-azure-image-builder): The latest stable build that's been tested, and reports no [General Data Protection Regulation (GDPR)](https://www.microsoft.com/trust-center/privacy/gdpr-overview) issues.
25+
* [*Stable* VM Image Builder task](https://marketplace.visualstudio.com/items?itemName=AzureImageBuilder.devOps-task-for-azure-image-builder): The latest stable build that's been tested, and reports no [General Data Protection Regulation (GDPR)](https://www.microsoft.com/trust-center/privacy/gdpr-overview) issues.
2626

27-
28-
* [*Unstable* VM Image Builder task](https://marketplace.visualstudio.com/items?itemName=AzureImageBuilder.devOps-task-for-azure-image-builder-canary): We offer a so-called *unstable* task so that you can test the latest updates and features before we release the task code as *stable*. After about a week, if there are no customer-reported or telemetry issues, we promote the task code to *stable*.
27+
* [*Unstable* VM Image Builder task](https://marketplace.visualstudio.com/items?itemName=AzureImageBuilder.devOps-task-for-azure-image-builder-canary): We offer a so-called *unstable* task so that you can test the latest updates and features before we release the task code as *stable*. After about a week, if there are no customer-reported or telemetry issues, we promote the task code to *stable*.
2928

3029
## Prerequisites
3130

@@ -39,12 +38,12 @@ Before you begin, you must:
3938
* Have an Azure DevOps Services (formerly Visual Studio Team Services, or VSTS) account, and a Build Pipeline created.
4039

4140
* Register and enable the VM Image Builder feature requirements in the subscription that's used by the pipelines:
42-
* [Azure PowerShell](../windows/image-builder-powershell.md#register-features)
43-
* [The Azure CLI](../windows/image-builder.md#register-the-features)
44-
41+
* [Azure PowerShell](../windows/image-builder-powershell.md#register-features)
42+
* [The Azure CLI](../windows/image-builder.md#register-the-features)
43+
4544
* Create a standard Azure storage account in the source image resource group. You can use other resource groups or storage accounts. The storage account is used transfer the build artifacts from the DevOps task to the image.
4645

47-
```powerShell
46+
```azurepowershell-interactive
4847
# Azure PowerShell
4948
$timeInt=$(get-date -UFormat "%s")
5049
$storageAccName="aibstorage"+$timeInt
@@ -53,7 +52,7 @@ Before you begin, you must:
5352
New-AzStorageAccount -ResourceGroupName $strResourceGroup -Name $storageAccName -Location $location -SkuName Standard_LRS
5453
```
5554
56-
```azurecli
55+
```azurecli-interactive
5756
# The Azure CLI
5857
location=westus
5958
scriptStorageAcc=aibstordot$(date +'%s')
@@ -78,12 +77,13 @@ In the dropdown list, select the subscription that you want VM Image Builder to
7877
### Resource group
7978
8079
Use the resource group where the temporary image template artifact will be stored. When you create a template artifact, another temporary VM Image Builder resource group, `IT_<DestinationResourceGroup>_<TemplateName>_guid`, is created. The temporary resource group stores the image metadata, such as scripts. At the end of the task, the image template artifact and temporary VM Image Builder resource group is deleted.
81-
80+
8281
### Location
8382
8483
The location is the region where VM Image Builder will run. Only a set number of [regions](../image-builder-overview.md#regions) are supported. The source images must be present in this location. For example, if you're using Azure Compute Gallery (formerly Shared Image Gallery), a replica must exist in that region.
8584
8685
### Managed identity (required)
86+
8787
VM Image Builder requires a managed identity, which it uses to read source custom images, connect to Azure Storage, and create custom images. For more information, see [Learn about VM Image Builder](../image-builder-overview.md#permissions).
8888
8989
### Virtual network support
@@ -95,11 +95,13 @@ You can configure the created VM to be in a specific virtual network. When you c
9595
The source images must be of the supported VM Image Builder operating systems. You can choose existing custom images in the same region that VM Image Builder is running from:
9696
9797
* Managed Image: Pass in the resource ID. For example:
98+
9899
```json
99100
/subscriptions/<subscriptionID>/resourceGroups/<rgName>/providers/Microsoft.Compute/images/<imageName>
100101
```
101102
102103
* Compute Gallery: Pass in the resource ID of the image version. For example:
104+
103105
```json
104106
/subscriptions/$subscriptionID/resourceGroups/$sigResourceGroup/providers/Microsoft.Compute/galleries/$sigName/images/$imageDefName/versions/<versionNumber>
105107
```
@@ -135,6 +137,7 @@ The task runs the following Windows Update configuration:
135137
"exclude:$_.Title -like '*Preview*'",
136138
"include:$true"
137139
```
140+
138141
The task installs important and recommended Windows Updates that aren't *preview* versions.
139142

140143
#### Handling reboots
@@ -151,73 +154,73 @@ Select the **Build Path** button to choose the build folder that you want to be
151154

152155
> [!IMPORTANT]
153156
> When you're adding a repo artifact, you might find that the directory name is prefixed with an underscore character (_). The underscore can cause issues with the inline commands. Be sure to use the appropriate quotation marks in the commands.
154-
>
157+
>
155158
156159
The following example explains how this works:
157160

158161
:::image type="content" source="./media/image-builder-devops-task/build-artifacts.png" alt-text="Screenshot of a directory structure showing hierarchy.":::
159162

160163
* For Windows: Files exist in the *C:* drive. A directory named *buildArtifacts* is created, which includes the *webapp* directory.
161164

162-
* For Linux: Files exist in the */tmp* directory. The *webapp* directory is created, which includes all the files and directories. Because this is a temporary directory, you must move the files out of it. Otherwise, they'll be deleted.
165+
* For Linux: Files exist in the `/tmp` directory. The `webapp` directory is created, which includes all the files and directories. Because this is a temporary directory, you must move the files out of it. Otherwise, they'll be deleted.
163166

164167
#### Inline customization script
165168

166169
* For Windows: You can enter PowerShell inline commands, separated by commas. If you want to run a script in your build directory, you can use:
167170

168-
```PowerShell
171+
```azurepowershell-interactive
169172
& 'c:\buildArtifacts\webapp\webconfig.ps1'
170173
```
171174
172175
You can reference multiple scripts or add more commands. For example:
173176
174-
```PowerShell
177+
```azurepowershell-interactive
175178
& 'c:\buildArtifacts\webapp\webconfig.ps1'
176179
& 'c:\buildArtifacts\webapp\installAgent.ps1'
177180
```
181+
178182
* For Linux: The build artifacts are put into the */tmp* directory. However, on many Linux operating systems, on a reboot, the */tmp* directory contents are deleted. If you want the artifacts to exist in the image, you must create another directory and copy them over. For example:
179183
180184
```bash
181185
sudo mkdir /lib/buildArtifacts
182186
sudo cp -r "/tmp/_ImageBuilding/webapp" /lib/buildArtifacts/.
183187
```
184-
188+
185189
If you're OK with using the */tmp* directory, you can run the script by using the following code:
186-
190+
187191
```bash
188192
# Grant execute permissions to run scripts
189193
sudo chmod +x "/tmp/_ImageBuilding/webapp/coreConfig.sh"
190194
echo "running script"
191195
sudo . "/tmp/AppsAndImageBuilderLinux/_WebApp/coreConfig.sh"
192196
```
193-
197+
194198
#### What happens to the build artifacts after the image build?
195199
196200
> [!NOTE]
197201
> VM Image Builder doesn't automatically remove the build artifacts. We strongly suggest that you always use code to remove the build artifacts.
198-
>
202+
>
199203
200204
* For Windows: VM Image Builder deploys files to the *C:\buildArtifacts* directory. Because the directory is persisted, you must remove it by running a script. For example:
201205
202-
```PowerShell
206+
```azurepowershell-interactive
203207
# Clean up buildArtifacts directory
204208
Remove-Item -Path "C:\buildArtifacts\*" -Force -Recurse
205209
206210
# Delete the buildArtifacts directory
207211
Remove-Item -Path "C:\buildArtifacts" -Force
208212
```
209-
213+
210214
* For Linux: The build artifacts are put into the */tmp* directory. However, on many Linux operating systems, the */tmp* directory contents are deleted on reboot. We suggest that you use code to remove the contents and not rely on the operating system to remove the contents. For example:
211215
212216
```bash
213217
sudo rm -R "/tmp/AppsAndImageBuilderLinux"
214218
```
215-
219+
216220
#### Total length of image build
217221
218222
Total length can't be changed in the DevOps pipeline task yet. It uses the default of 240 minutes. If you want to increase the [buildTimeoutInMinutes](./image-builder-json.md#properties-buildtimeoutinminutes), you can use an Azure CLI task in the release pipeline. Configure the task to copy a template and submit it. For an example solution, see [Use environment variables and parameters with VM Image Builder](https://github.com/danielsollondon/azvmimagebuilder/tree/master/solutions/4_Using_ENV_Variables#using-environment-variables-and-parameters-with-image-builder), or use Azure PowerShell.
219223
220-
221224
#### Storage account
222225
223226
Select the storage account you created in the prerequisites. If you don't see it in the list, VM Image Builder doesn't have permissions to it.
@@ -236,7 +239,7 @@ The following three distribute types are supported.
236239
237240
* Resource ID:
238241
239-
```bash
242+
```azurecli-interactive
240243
/subscriptions/<subscriptionID>/resourceGroups/<rgName>/providers/Microsoft.Compute/images/<imageName>
241244
```
242245
@@ -246,9 +249,9 @@ The following three distribute types are supported.
246249
247250
The Compute Gallery must already exist.
248251
249-
* Resource ID:
252+
* Resource ID:
250253
251-
```bash
254+
```azurecli-interactive
252255
/subscriptions/<subscriptionID>/resourceGroups/<rgName>/providers/Microsoft.Compute/galleries/<galleryName>/images/<imageDefName>
253256
```
254257
@@ -274,7 +277,7 @@ The task uses the properties that are passed to the task to create the VM Image
274277
275278
Example output:
276279
277-
```text
280+
```output
278281
start reading task parameters...
279282
found build at: /home/vsts/work/r1/a/_ImageBuilding/webapp
280283
end reading parameters
@@ -288,13 +291,13 @@ starting put template...
288291

289292
When the image build starts, the run status is reported in the release logs:
290293

291-
```text
294+
```output
292295
starting run template...
293296
```
294297

295298
When the image build finishes, the output is similar to following text:
296299

297-
```text
300+
```output
298301
2019-05-06T12:49:52.0558229Z starting run template...
299302
2019-05-06T13:36:33.8863094Z run template: Succeeded
300303
2019-05-06T13:36:33.8867768Z getting runOutput for SharedImage_distribute
@@ -314,7 +317,7 @@ You can take the `$(imageUri)` Azure DevOps Services (formerly Visual Studio Tea
314317

315318
## Output DevOps variables
316319

317-
Here are the publisher, offer, SKU, and version of the source marketplace image:
320+
Here is the publisher, offer, SKU, and version of the source marketplace image:
318321

319322
* `$(pirPublisher)`
320323
* `$(pirOffer)`
@@ -359,7 +362,6 @@ template name: t_1556938436xxx
359362

360363
The VM Image Builder template resource artifact is in the resource group that was specified initially in the task. When you're done troubleshooting, delete the artifact. If you're deleting it by using the Azure portal, within the resource group, select **Show Hidden Types** to view the artifact.
361364

362-
363365
## Next steps
364366

365-
For more information, see [VM Image Builder overview](../image-builder-overview.md).
367+
For more information, see [VM Image Builder overview](../image-builder-overview.md).

0 commit comments

Comments
 (0)