question

SenhorDolas-2197 avatar image
0 Votes"
SenhorDolas-2197 asked SenhorDolas-2197 commented

Azure Image Builder - Image version name

Very new to this so bear with me.

I have been following up Azure Academy videos on how to setup an AIB pipeline and install apps on my template VM.

This works fine (I have more questions about Azure Repo but I will post separately) but the image version comes out with a funny name, is it possible to name the image version (see pic for example)

111268-capture.png



Cheers, M

azure-virtual-machines-imagesazure-dev-tool-integrations
capture.png (10.0 KiB)
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi Everyone,

Sorry for the late reply!

I am still not sure how to set an image version via Azure DevOps Azure Image builder.

Is there a way at all?

Thanks M

0 Votes 0 ·
kobulloc-MSFT avatar image
0 Votes"
kobulloc-MSFT answered kobulloc-MSFT edited

Welcome to Azure!

The short answer is that you can't rename resources (it's a popular request) but there's a lot that can be done during the resource creation process and there is a workaround if you find yourself needing to change the name of a resource group.


What determines my resource name?
Typically resources are named based on a name you provide either while configuring the resource or based on the resource group. For example, if you were to create a resource group named "AzureVMQuickstart" and then create a VM in the portal named "MyFirstVM", you'd get the following resources:

  • MyFirstVM (Virtual machine)

  • MyFirstVM-ip (Public IP address)

  • MyFirstVM-nsg (Network security group)

  • AzureVMQuickstart-vnet (Virtual network)

  • MyFirstVM_OSDisk_1h3s4bcc97lw204... (Disk)

  • MyFirstVM-13254 (Network interface)

There are some exceptions to this rule where you'll see a long string of characters for something but in general it's pretty clear what either the resource group name was or the resource name it was created from.


How do I change my resource or resource group name?
Changing the names of resource groups or resources once they've been made is one of the more popular requests that's still outstanding:

Voting on this helps to improve visibility and priority so I would encourage you to vote if you would like to see these features added.

While you can't change a resource group name, you can move all of the resources from your old resource group to a new resource group with a new name. This can take some time, however, and isn't recommended as part of a normal workflow.

This is a good writeup on how to move resources from one resource group to another from Steve Sherry:
https://adamtheautomator.com/rename-azure-resource-group/

As well as another simple CLI/PowerShell example along with an explanation on why this happens by Matthias Güntert:
https://www.azureblue.io/how-to-rename-an-azure-resource-group/

As far as resources are concerned, unfortunately those cannot be renamed at this time. Most often you do have some degree of control over the name during creation, however, which should help.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

SenhorDolas-2197 avatar image
0 Votes"
SenhorDolas-2197 answered

@kobulloc-MSFT
Sorry, did not see your reply (no alert in my email for some reason)
Thanks for coming back to me.
I understand that I cant rename RG and resources but my question was move about the image version naming?
Since this is created via automation from Azure Image Builder I am guessing it will be an automated name and as such at this stage there is nothing we can do?
M

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

kobulloc-MSFT avatar image
0 Votes"
kobulloc-MSFT answered SchroederMichaelCTR-6688 commented

@SenhorDolas-2197 Thank you again for being patient and sorry for the delay. From the documentation regarding the resource group naming convention:

https://docs.microsoft.com/en-us/azure/virtual-machines/image-builder-overview#how-it-works

Template configurations can be passed using PowerShell, Az CLI, ARM templates and using the Azure VM Image Builder DevOps task, when you submit it to the service we will create an Image Template Resource. When the Image Template Resource is created you will see a staging resource group created in your subscription, in the format: IT_<DestinationResourceGroup><TemplateName>(GUID). The staging resource group contains files and scripts referenced in the File, Shell, PowerShell customization in the ScriptURI property.

As for the resources and templates, there are a couple key steps regarding naming (using CLI on Windows here as an example):

https://docs.microsoft.com/en-us/azure/virtual-machines/windows/image-builder#set-variables

 # Resource group name - we are using myImageBuilderRG in this example
 imageResourceGroup=myWinImgBuilderRG
    
 # Name for the image 
 imageName=myWinBuilderImage

https://docs.microsoft.com/en-us/azure/virtual-machines/windows/image-builder#create-the-image

(Paying attention to the value for -n)

 az resource create \
     --resource-group $imageResourceGroup \
     --properties @helloImageTemplateWin.json \
     --is-full-object \
     --resource-type Microsoft.VirtualMachineImages/imageTemplates \
     -n helloImageTemplateWin01

Let me know if you need more detail here. Additionally, there are some resources that might help (I usually recommend going through the docs when you are first learning about a service):

· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.


@kobulloc-MSFT
Thanks for your reply.

II am creating my template from Azure Image Builder and I cannot see a way to declare the template name on the form provided.
Yes I can do it if I command line it but I don't think there is an option in AIB.
If you have a way please let me know? :)
Thanks, M

0 Votes 0 ·

@SenhorDolas-2197 No worries! Azure Image Builder template configurations are passed using PowerShell, Az CLI, Arm templates and using the Azure VM Image Builder DevOps task. Going through the video you linked in your question, it looks like they are using PowerShell.

The resource in your screenshot appears to be created at 29m 17s which would be based on the Start-AzImageBuilderTemplate command at 26m 01s that creates the resource using the template file in the demo.

117562-image.png

I wouldn't recommend editing the template but you can read more in the documentation here:

0 Votes 0 ·
image.png (197.5 KiB)
SchroederMichaelCTR-6688 avatar image
0 Votes"
SchroederMichaelCTR-6688 answered

The answer to this question can be found here: https://github.com/MicrosoftDocs/azure-docs/issues/89180#issuecomment-1063218290

Version is specified in the GalleryImageId property of the "distribute" block. Use one of two formats:

-> Automatic versioning - This is the automatic version number you are seeing. The format is:
/subscriptions/<subscriptionId>/resourceGroups/<resourceGroupName>/providers/Microsoft.Compute/galleries/<sharedImageGalleryName>/images/<imageGalleryName>

-> Explicit versioning - This is what you're after. It allows you to specify the version number. The format is:
/subscriptions/<subscriptionID>/resourceGroups/<rgName>/providers/Microsoft.Compute/galleries/<sharedImageGalName>/images/<imageDefName>/versions/<version - for example: 1.1.1>

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

SenhorDolas-2197 avatar image
0 Votes"
SenhorDolas-2197 answered

Hi Everyone,

I see that there is a way of specifying Image version name via json but is there a way for the "Azure VM Image Builder Task" which I use from DevOps?

On a separate note, how do I create a json script based on what I have setup in AIB task? I really don't know how to make the transition which I think I need to cos the task is very limited?

Thanks Everyone

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.