You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This article shows you how you can use the Azure Image Builder, and the Azure CLI, to create an image version in an [Azure Compute Gallery](../shared-image-galleries.md) (formerly known as Shared Image Gallery), then distribute the image globally. You can also do this using [Azure PowerShell](../windows/image-builder-gallery.md).
19
19
20
-
21
20
We will be using a sample .json template to configure the image. The .json file we are using is here: [helloImageTemplateforSIG.json](https://github.com/azure/azvmimagebuilder/blob/master/quickquickstarts/1_Creating_a_Custom_Linux_Shared_Image_Gallery_Image/helloImageTemplateforSIG.json).
22
21
23
22
To distribute the image to an Azure Compute Gallery, the template uses [sharedImage](image-builder-json.md#distribute-sharedimage) as the value for the `distribute` section of the template.
24
23
25
-
26
24
## Register the features
27
25
28
26
To use Azure Image Builder, you need to register the feature.
@@ -47,7 +45,7 @@ az provider register -n Microsoft.Storage
47
45
az provider register -n Microsoft.Network
48
46
```
49
47
50
-
## Set variables and permissions
48
+
## Set variables and permissions
51
49
52
50
We will be using some pieces of information repeatedly, so we will create some variables to store that information.
53
51
@@ -81,9 +79,10 @@ az group create -n $sigResourceGroup -l $location
81
79
```
82
80
83
81
## Create a user-assigned identity and set permissions on the resource group
82
+
84
83
Image Builder will use the [user-identity](../../active-directory/managed-identities-azure-resources/qs-configure-cli-windows-vm.md#user-assigned-managed-identity) provided to inject the image into the Azure Compute Gallery. In this example, you will create an Azure role definition that has the granular actions to perform distributing the image to the gallery. The role definition will then be assigned to the user-identity.
85
84
86
-
```bash
85
+
```azurecli-interactive
87
86
# create user assigned identity for image builder to access the storage account where the script is located
88
87
identityName=aibBuiUserId$(date +'%s')
89
88
az identity create -g $sigResourceGroup -n $identityName
To use Image Builder with an Azure Compute Gallery, you need to have an existing gallery and image definition. Image Builder will not create the gallery and image definition for you.
@@ -140,7 +138,6 @@ az sig image-definition create \
140
138
--os-type Linux
141
139
```
142
140
143
-
144
141
## Download and configure the .json
145
142
146
143
Download the .json template and configure it with your variables.
@@ -184,7 +181,6 @@ az resource invoke-action \
184
181
185
182
Creating the image and replicating it to both regions can take a while. Wait until this part is finished before moving on to creating a VM.
186
183
187
-
188
184
## Create the VM
189
185
190
186
Create a VM from the image version that was created by Azure Image Builder.
@@ -219,7 +215,6 @@ You should see the image was customized with a *Message of the Day* as soon as y
219
215
220
216
If you want to now try re-customizing the image version to create a new version of the same image, skip the next steps and go on to [Use Azure Image Builder to create another image version](image-builder-gallery-update-image-version.md).
221
217
222
-
223
218
This will delete the image that was created, along with all of the other resource files. Make sure you are finished with this deployment before deleting the resources.
224
219
225
220
When deleting gallery resources, you need delete all of the image versions before you can delete the image definition used to create them. To delete a gallery, you first need to have deleted all of the image definitions in the gallery.
@@ -234,6 +229,7 @@ az resource delete \
234
229
```
235
230
236
231
Delete permissions assignments, roles and identity
0 commit comments