• About
  • Advertise
  • Careers
  • Contact Us
Monday, June 16, 2025
  • Login
No Result
View All Result
NEWSLETTER
Tech | Business | Economy
  • News
  • Tech
    • DisruptiveTECH
    • ConsumerTech
    • How To
    • TechTAINMENT
  • Business
    • Mobility
    • Environment
    • Travel
    • StartUPs
  • Economy
  • TECHECONOMY TV
  • TBS
  • About Us
  • Contact Us
  • Telecoms
  • News
  • Tech
    • DisruptiveTECH
    • ConsumerTech
    • How To
    • TechTAINMENT
  • Business
    • Mobility
    • Environment
    • Travel
    • StartUPs
  • Economy
  • TECHECONOMY TV
  • TBS
  • About Us
  • Contact Us
  • Telecoms
No Result
View All Result
Tech | Business | Economy
No Result
View All Result
ADVERTISEMENT
Home How To

Automating the Creation of Custom Image Build Using Azure Image Builder

Traditional VM image creation requires manual setup, installation, and configuration, which is time-consuming and error-prone. Azure Image Builder automates this process, PAUL UDOMI writes:

by Techeconomy
March 21, 2025
in How To
0
Azure Image Builder by Paul Udomi
Paul Udomi

Paul Udomi

UBA
Advertisements

Introduction to Azure Image Builder

Azure Image Builder (AIB) is a managed service that simplifies the process of creating, customizing, and distributing virtual machine (VM) images across Azure.

It leverages Azure Resource Manager (ARM) templates or Bicep to automate the image-building process, ensuring consistency and security across deployments.

Why Use Azure Image Builder?

Traditional VM image creation requires manual setup, installation, and configuration, which is time-consuming and error-prone. Azure Image Builder automates this process, offering:

  • Consistency — Ensures every image is built with the same configuration.
  • Security — Allows pre-installation of security patches, compliance tools, and monitoring agents.
  • Efficiency — Reduces manual effort and automates image lifecycle management.
  • Multi-cloud & Hybrid Support — Supports deployment across Azure, on-premises, and even other clouds.

Key Features of Azure Image Builder

  • Custom Image Definitions — Define VM images with required OS, software, and configurations.
  • Image Templates — Specify the source, distribution method, and customization steps.
  • Integration with DevOps Pipelines — Automate image building using CI/CD workflows.
  • Shared Image Gallery Support — Store and manage images centrally for reuse.
  • Support for Windows and Linux Images — Build images for different OS environments.

Prerequisites for Running This Project

  1. Configure a self-hosted agent.
  2. Create a new or use an existing virtual network (az-uks-np01-aib-lan-vnet)
  3. Create a new or use an existing Managed Identity and assign the required RBAC role.
  4. Ensure existing resource groups are available:
    az-uks-np01-gallery-rg
    az-uks-np01-network-rg
    az-uks-np01-win-2019-aib-rg

Repository Structure for Image Builder Automation

Here’s the directory structure of our Azure Image Builder automation project:

infrastructure.platform.AIB  
│── infra  
│   ├── images  
│   │   ├── placeholder.json  
│   │   ├── ubuntu-pro-2204.bicep  
│   │   ├── win-2019.bicep  
│   ├── modules  
│   │   ├── imageDefinition.bicep  
│   │   ├── imageTemplate.bicep  
│── pipeline  
│   ├── azure-pipeline-images.yml  
│── README.md

Breakdown of Repository Components

  • infra/images/ – Contains Bicep templates for defining images (Windows 2019, Ubuntu Pro 22.04).
  • infra/modules/ – Reusable Bicep modules for defining Image Definition and Image Template.
  • pipeline/azure-pipeline-images.yml – Azure DevOps pipeline script that automates image creation.
  • README.md – Documentation for setup and usage.

Understanding Image Definition & Image Template

Image Definition (imageDefinition.bicep)

Defines the image structure within an Azure Shared Image Gallery, including:

  • OS type (Windows/Linux).
  • Publisher and offer details.
  • Shared Image Gallery location.

Image Template (imageTemplate.bicep)

Specifies the actual image customization process, including:

  • Base OS Image (e.g., Windows Server 2019).
  • Custom scripts (installing software, security updates).
  • Distribution method (Shared Image Gallery, Managed Image).

Automating Image Builds Using Azure DevOps Pipelines

Now, let’s dive into the CI/CD pipeline that automates the Azure Image Builder process.

Pipeline Configuration (azure-pipeline-images.yml)

Triggering & Scheduling

  • Runs manually or on a monthly schedule (8 AM UTC on the 14th of each month).
schedules:
  - cron: "0 8 14 * *"
    displayName: Monthly build
    branches:
     include:
     - main
    always: true

Pipeline Parameters

  • Supports Windows 2019 and Ubuntu Pro 22.04 as build options.
  • Allows selecting between beta and stable environments.
parameters:
- name: mode
  type: string
  default: stable
  values:
    - beta
    - stable
- name: image
  type: string
  default: win-2019
  values:
    - win-2019
    - ubuntu-pro-2204

Pipeline Variables

  • Sets environment-specific values for resource groups, subscriptions, and service connections.
variables:
  - name: imageTemplateName
    value: <image template name>
  - name: fileToRun
    value: infrastructure.platform.AIB/infra/images/${{ parameters.image }}.bicep
  - name: version
    value: '$(Build.BuildNumber)'

Pipeline Stages

1. Build Stage — Compile Bicep Files

  • Checks out the repository.
  • Lists files in the source directory.
  • Builds the Bicep templates before deployment.
stages:
  - stage: Build
    displayName: 'Build Bicep'
    pool: $(agentPool)
    jobs:
      - job: BuildBicep
        steps:
          - checkout: self 
          - script: |
              echo "Listing files in $(Build.SourcesDirectory):"
              dir $(Build.SourcesDirectory)
            displayName: 'List Files in Sources Directory'
          - task: AzureCLI@2
            inputs:
              azureSubscription: $(serviceConnection)
              scriptType: "ps"
              scriptLocation: "inlineScript"
              inlineScript: |
                az bicep build --file $(fileToRun)

2. Deploy Stage — Deploy Image Builder Components

  • Deploys Image Definition and Image Template to Azure.
- stage: Deploy
    displayName: 'Deploy Bicep'
    pool: $(agentPool)
    jobs:
      - job: DeployBicep
        steps:
          - task: AzureCLI@2
            inputs:
              azureSubscription: $(serviceConnection)
              scriptType: "ps"
              scriptLocation: "inlineScript"
              inlineScript: |
                az deployment group create --name Image_$(Build.BuildId) \
                  --resource-group 'az-uks-${{ variables.environment }}-gallery-rg' \
                  --template-file $(fileToRun) \
                  --parameters infrastructure.platform.AIB/infra/images/placeholder.json \
                  version=$(version) environment=$(environment) name=${{ parameters.image }}

3. Build Image Stage — Execute Image Builder Process

  • Triggers Azure Image Builder to create the VM image.
  • Waits for image build completion.
- stage: BuildImage
    displayName: 'Build Image'
    dependsOn: Deploy
    pool: $(agentPool)
    jobs:
      - job: BuildImage
        timeoutInMinutes: 120
        steps:
          - task: AzureCLI@2
            inputs:
              azureSubscription: $(serviceConnection)
              scriptType: "ps"
              scriptLocation: "inlineScript"
              inlineScript: |
                az image builder run --name ${{ variables.imageTemplateName }} \
                  --resource-group 'az-uks-${{ variables.environment }}-gallery-rg' --no-wait
                az image builder wait --name ${{ variables.imageTemplateName }} \
                  --resource-group 'az-uks-${{ variables.environment }}-gallery-rg' \
                  --custom "lastRunStatus.runState!='Running'"

Key Benefits of This Approach:

  • Eliminates manual VM configuration.
  • Ensures compliance with security policies.
  • Reduces operational overhead.
  • Enables version-controlled image updates.

Code to the project repository can be found in the link: https://dev.azure.com/pauludomi0161/MiniLab/_git/infrastructure.platform.AIB

OUTPUT OF PIPELINE RUN IN AZURE PORTAL

Azure Compute Gallery RG:

Advertisements
MTN ADS

*Paul Udomi, an IT Cloud Engineer is on LinkedIn.

Loading

0Shares
Tags: Azure Image BuilderCustom Image BuildIT Cloud EngineerPaul Udomi
Techeconomy

Techeconomy

Next Post
AfDB and Smallholder Farmers

AfDB Mulls $500M Facility to Mobilize Financing for Smallholder Farmers

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Recommended

[BREAKING ]WhatsApp Rolls Out ‘Communities’ – 32-Person Video Calls, 1024 Group Members

3 years ago
PenPay and Quickteller

PenPay and Quickteller to Jointly Provide Informal Sector Workers with Retirement Savings Plans

2 years ago

Popular News

    Connect with us

    Currently Playing

    How to be productive this year ! #productivity #timelimit

    How to be productive this year ! #productivity #timelimit

    00:00:51

    TE Weather

    TE PODCAST

    Techeconomy Podcast
    Techeconomy Podcast

    Every week we will bring new stories from startups and influencers who are shaping and changing the world we live in. We’ll also bring you reports on topics you should know.

    Follow us @techeconomyng for more.

    Listen OnSpotify
    TECH TALK EPISODE 2
    byTecheconomy

    PRODUCTIVITY AND WORK-Life Balance

    TECH TALK EPISODE 2
    Episode play icon
    TECH TALK EPISODE 2
    Episode Description
    Episode play icon
    CYBERSECURITY ESSENTIALS
    Episode Description
    Episode play icon
    Digital Marketing Trends and strategies for 2025 and beyond
    Episode Description
    Episode play icon
    Major Lesson for Techies in 2024 and Projections for 2025
    Episode Description
    Episode play icon
    Major Lessons for Techies in an AI-Driven World | Techeconomy Business Series Highlights
    Episode play icon
    Maximizing Profitability Through Seasonal Sales: Strategies For Success
    Episode play icon
    Techeconomy Business Series
    Episode Description
    Episode play icon
    PRIVACY IN THE ERA OF AI: GETTING YOUR BUSINESS READY
    Episode Description
    Episode play icon
    Unravel the Secrets of Marketing Everywhere All At Once with Isaac Akanni from Infobip | Infowave Podcast Episode 1
    Episode Description
    Episode play icon
    The Role of Ed-tech in Life Long Learning and Continuous Education
    Episode Description
    Search Results placeholder
    • About
    • Advertise
    • Careers
    • Contact Us

    © 2017 TECHECONOMY.

    No Result
    View All Result
    • News
    • Tech
      • DisruptiveTECH
      • ConsumerTech
      • How To
      • TechTAINMENT
    • Business
      • Mobility
      • Environment
      • Travel
      • StartUPs
    • Economy
    • TECHECONOMY TV
    • TBS
    • About Us
    • Contact Us

    © 2017 TECHECONOMY.

    Welcome Back!

    Login to your account below

    Forgotten Password?

    Retrieve your password

    Please enter your username or email address to reset your password.

    Log In
    Translate »