Professor Dr. Kazemi

CPO550 Lab 07

Create custom session host images by using image templates — Interactive Lab Manual · Fall 2026

Task 1: Register required resource providers 10 pts

  1. Note: if prompted, in the Getting started pane, in the Subscription drop-down list, select the name of the Azure subscription you are using in this lab and then select Apply.

  2. Register-AzResourceProvider -ProviderNamespace Microsoft.DesktopVirtualization
    Register-AzResourceProvider -ProviderNamespace Microsoft.VirtualMachineImages
    Register-AzResourceProvider -ProviderNamespace Microsoft.Storage
    Register-AzResourceProvider -ProviderNamespace Microsoft.Compute
    Register-AzResourceProvider -ProviderNamespace Microsoft.Network
    Register-AzResourceProvider -ProviderNamespace Microsoft.KeyVault
    Register-AzResourceProvider -ProviderNamespace Microsoft.ContainerInstance

    Note: do not wait for the registration to complete. This might take about 5 minutes.

Task 2: Create a user-assigned managed identity 10 pts

  1. SettingValue
    Subscriptionthe name of the Azure subscription you are using in this lab
    Resource groupthe name of a new resource group <sName>-cpoF67-7-RG
    Regionthe name of the Azure region where you want to deploy your Azure Virtual Desktop environment
    Name<sName>-cpoF67-uami
  2. Screenshot must show your Odl_user account, the <sName>-cpoF67-uami user-assigned managed identity you created

Task 3: Create a custom Azure role-based access control (RBAC) role 10 pts

Note: the custom RBAC role will be used to assign appropriate permissions to the user-assigned managed identity created in the previous task.

  1. $subscriptionId = (Get-AzSubscription).Id
  2. $jsonContent = @"
    { "Name": "Desktop Virtualization Image Creator (<sName>)", "IsCustom": true, "Description": "Create custom image templates for Azure Virtual Desktop images.", "Actions": [ "Microsoft.Compute/galleries/read", "Microsoft.Compute/galleries/images/read", "Microsoft.Compute/galleries/images/versions/read", "Microsoft.Compute/galleries/images/versions/write", "Microsoft.Compute/images/write", "Microsoft.Compute/images/read", "Microsoft.Compute/images/delete" ], "NotActions": [], "DataActions": [], "NotDataActions": [], "AssignableScopes": [ "/subscriptions/$subscriptionId", "/subscriptions/$subscriptionId/resourceGroups/<sName>-cpoF67-72-RG" ] }
    "@
  3. $jsonContent | Out-File -FilePath 'CustomRole.json'
  4. New-AzRoleDefinition -InputFile ./CustomRole.json
  5. Screenshot must show your Odl_user account, the Cloud Shell with the Desktop Virtualization Image Creator custom role created via New-AzRoleDefinition

Task 4: Set permissions on the host image provisioning-related resources 10 pts

  1. SettingValue
    Subscriptionthe name of the Azure subscription you are using in this lab
    Resource groupthe name of a new resource group <sName>-cpoF67-72-RG
    Regionthe name of the Azure region where you want to deploy your Azure Virtual Desktop environment
  2. Screenshot must show your Odl_user account, the Desktop Virtualization Image Creator role assignment to <sName>-cpoF67-uami on <sName>-cpoF67-72-RG

Task 5: Create an Azure Compute Gallery instance and an image definition 10 pts

  1. SettingValue
    Subscriptionthe name of the Azure subscription you are using in this lab
    Resource group<sName>-cpoF67-72-RG
    Name<sName>_cpoF67_Gallery
    Regionthe name of the Azure region where you want to deploy your Azure Virtual Desktop environment
  2. Note: wait for the provisioning process to complete. This should take less than 1 minute.

  3. SettingValue
    Regionthe name of the Azure region where you want to deploy your Azure Virtual Desktop environment
    VM image definition name<sName>-cpoF67-ImageDefinition
    OS typeWindows
    Security typeTrusted launch supported
    OS stateGeneralized
    PublisherMicrosoftWindowsDesktop
    OfferWindows-11
    SKUwin11-23h2-avd-m365

    Note: VM generation is automatically set to Gen2, because Gen 1 virtual machines are not supported with Trusted and Confidential security type.

  4. Note: you should not create the VM image version at this stage. This will be done by Azure Virtual Desktop.

  5. SettingValue
    Recommended VM vCPUsmove slider to show 2 on the right side
    Recommended VM memorymove slider to show 8 on the right side
    Excluded disk typesselect Premium SSD
  6. Screenshot must show your Odl_user account, the <sName>-cpoF67-ImageDefinition created in <sName>_cpoF67_Gallery

    Note: wait for the provisioning process to complete. This typically takes less than 1 minute.

Task 6: Create a custom image template 10 pts

  1. SettingValue
    Template name<sName>-cpoF67-ImageTemplate
    Import from existing templateNo
    Subscriptionthe name of the Azure subscription you are using in this lab
    Resource group<sName>-cpoF67-72-RG
    Locationthe name of the Azure region where you want to deploy your Azure Virtual Desktop environment (East US)
    Managed identity<sName>-cpoF67-uami
  2. SettingValue
    Source typePlatform image (marketplace)
    Select imageWindows 11 Enterprise multi-session, Version 23H2 + Microsoft 365 Apps
  3. SettingValue
    Azure Compute Galleryenabled
    Gallery name<sName>_cpoF67_Gallery
    Gallery image definition<sName>-cpoF67-ImageDefinition
    Gallery image version1.0.0
    Run output namecpoF67-image-1.0.0
    Replication regionsthe name of the Azure region where you want to deploy your Azure Virtual Desktop environment
    Exclude from latestNo
    Storage account typeStandard_LRS

    Note: you can use the Replication regions property to accommodate multi-region builds. Setting Exclude from latest to Yes would prevent this image version from being used when latest is specified as the version of the ImageReference element during VM creation.

  4. SettingValue
    Build timeout120
    Build VM sizeStandard_D2s_v3
    OS disk size (GB)127
    Staging groupcpoF67-73-RG
    VNetleave not set

    Note: Staging group is the resource group used to stage resources to build the image and store logs. If you don't provide its name, it will be automatically generated. If the VNet name is not set, a temporary one is created, along with a public IP address for the VM used to create the build.

  5. Note: you have the option of adding your own scripts. For examples, consider referencing the built-in scripts, such as Time zone redirection, Disable Storage Sense, or Enable screen capture protection.

  6. Screenshot must show your Odl_user account, the <sName>-cpoF67-ImageTemplate in the Custom image templates list

Task 7: Build a custom image 10 pts

Note: the remaining tasks of this lab involve a fairly extensive wait time.

  1. Note: the build run state should change at some point from Running - Building to Running - Distributing and finally to Succeeded.

  2. Note: alternatively, you can use Activity Log to keep track of the completion of the build process. The action you should focus on is Execute a VM image template to produce its output. Its status should change at some point from Accepted to Succeeded.

  3. Screenshot must show your Odl_user account, the <sName>-cpoF67-ImageDefinition with image version 1.0.0 in <sName>_cpoF67_Gallery

Task 8: Deploy session hosts by using a custom image 10 pts

Note: step through the initial stages of deploying Azure Virtual Desktop session hosts by using the custom image you created. Generate key when adding new session hosts.

  1. SettingValue
    Add virtual machinesYes
    Resource group<sName>-cpoF67-21e-RG
    Name prefix<sName>-img
    Virtual machine typeAzure virtual machine
    Virtual machine locationthe name of the Azure region where you want to deploy your Azure Virtual Desktop environment
    Availability optionsNo infrastructure redundancy required
    Security typeTrusted launch virtual machines
  2. SettingValue
    Image<sName>_cpoF67_Gallery/<sName>-cpoF67-ImageDefinition/1.0.0
    Virtual machine sizeStandard D2s_v3
    Number of VMs1
    OS disk typeStandard HDD
    OS disk sizeDefault size
    Boot DiagnosticsDisabled
    Virtual networkcpoF67-vnet11e
    Subnethp1-Subnet
    Network security groupBasic
    Public inbound portsNo
    Select which directory you would like to joinMicrosoft Entra ID
    Enroll VM with IntuneNo
    User nameAdminuser
    Passwordprovide a complex password
    Confirm passwordretype the password
  3. Note: wait for the deployment to complete. This might take about 10-15 minutes.

  4. Screenshot must show your Odl_user account, the session hosts <sName>-img deployed from the custom image with status Available

Task 9: Summary Questions 20 pts

Minimum 2-3 sentences each — original thinking, your own words!

Your submission preview

Screenshots you attach above and your Task 9 answers appear here. This is exactly what prints/exports as your PDF.

Submit compile & export