# spoddar13/azure_imagebuilder architecture

> Architecture diagram of the GitHub repository spoddar13/azure_imagebuilder, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-24). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/spoddar13/azure_imagebuilder
- Repository: https://github.com/spoddar13/azure_imagebuilder

## Overview

##### Project type and purpose
- This is a small automation toolkit for Azure VM image creation. It leverages Azure Image Builder via ARM templates (.json) and PowerShell scripts (.ps1). There is no traditional “frontend/backend” web app here—rather, it’s an infrastructure-as-code (IaC) project that configures and orchestrates Azure services to produce custom VM images.

##### File structure
- Top‐level files:
- ImageTemplateWin.json, RoleImageCreation.json – ARM (Azure Resource Manager) templates defining the image build pipeline and the managed identity/role assignments.
- psimagebuilder.ps1, testPsScript.ps1 – PowerShell scripts to deploy the templates or run test builds.
- index.html – likely a static documentation or quick‐start page.
- ps/.gitkeep – placeholder to keep an empty directory under source control.
- README.md – minimal, only carries the project title (“azure_imagebuilder”).
- LICENSE – standard licensing info.

##### README for additional insights
- The README only names the project. We infer functionality from file names:
- “ImageTemplateWin” suggests a Windows‐based image template.
- “RoleImageCreation” suggests that the project also creates or assigns roles/MIs.

##### Main components
a. User (DevOps engineer)
b. PowerShell orchestration layer
- psimagebuilder.ps1 – deploys the Image Template + Role Template
- testPsScript.ps1 – validates or test‐runs the build
c. ARM Template artifacts
- ImageTemplateWin.json – defines source image, customizations, Azure compute gallery target
- RoleImageCreation.json – defines managed identity, role assignments for the builder
d. Azure services invoked
- Azure Resource Manager (deployment endpoint)
- Azure Image Builder service
- Azure Compute Gallery (or Shared Image Gallery) – to store resulting images
- Optional: Key Vault, Storage Account, or other resources referenced in the templates

##### Relationships and interactions
1. The user runs psimagebuilder.ps1 locally (or via CI/CD).
2. The script calls Azure Resource Manager REST API or Azure PowerShell cmdlets, passing in the ARM templates (JSON files).
3. ARM service validates and starts a deployment, which:
– Creates (or ensures) a managed identity and role assignment (via RoleImageCreation.json).
– Submits an Image Builder definition (ImageTemplateWin.json) to the Azure Image Builder service.
4. Azure Image Builder spins up a temporary builder VM, applies customizations, captures an image, and publishes it to the Compute Gallery.
5. testPsScript.ps1 can be used to poll or verify that the build completed successfully.

##### Architectural patterns and design principles
- IaC pattern: infrastructure and configuration defined as code (ARM JSON + scripts).
- Separation of concerns:
- Templates (declarative resources)
- Scripts (imperative orchestration)
- Principle of least privilege: RoleImageCreation.json ensures the builder runs under a specific managed identity with minimal required roles.

## Diagram (Mermaid)

```mermaid
flowchart TD
    U["User / DevOps Engineer"]:::actor
    subgraph "PowerShell Orchestration"
        PS1["psimagebuilder.ps1"]:::script
        PS2["testPsScript.ps1"]:::script
    end
    subgraph "ARM Templates"
        T1["ImageTemplateWin.json"]:::template
        T2["RoleImageCreation.json"]:::template
    end
    ARM["Azure Resource Manager"]:::service
    MI["Managed Identity & Role Assignment"]:::resource
    IBdef["Azure Image Builder Definition"]:::service
    VM["Temporary Builder VM"]:::resource
    CG["Azure Compute Gallery"]:::service

    U -->|"run orchestration"| PS1
    U -->|"(optional) test build"| PS2
    PS1 -->|"az deployment group create"| ARM
    ARM -->|"create identity & roles"| MI
    ARM -->|"submit builder definition"| IBdef
    IBdef -->|"provision & customize"| VM
    VM -->|"publish image"| CG
    PS2 -.->|"poll build status"| IBdef

    click PS1 "https://github.com/spoddar13/azure_imagebuilder/blob/main/psimagebuilder.ps1"
    click PS2 "https://github.com/spoddar13/azure_imagebuilder/blob/main/testPsScript.ps1"
    click T1 "https://github.com/spoddar13/azure_imagebuilder/blob/main/ImageTemplateWin.json"
    click T2 "https://github.com/spoddar13/azure_imagebuilder/blob/main/RoleImageCreation.json"
    click U "https://github.com/spoddar13/azure_imagebuilder/blob/main/index.html"
    click U "https://github.com/spoddar13/azure_imagebuilder/blob/main/README.md"
    click PS1 "https://github.com/spoddar13/azure_imagebuilder/blob/main/ps/.gitkeep"
    click PS1 "https://github.com/spoddar13/azure_imagebuilder/tree/main/LICENSE"

    classDef actor fill:#d3d3d3,stroke:#333,stroke-width:1px;
    classDef script fill:#cce5ff,stroke:#3399ff,stroke-width:1px;
    classDef template fill:#d4edda,stroke:#28a745,stroke-width:1px;
    classDef service fill:#ffe5b4,stroke:#ff8c00,stroke-width:1px;
    classDef resource fill:#f8d7da,stroke:#dc3545,stroke-width:1px;
```
