Skip to content

Image Builder hangs when building template with anything other than System Elevated powershell script/command #53

Open

Description

I'm using the base image Windows 11 + VS 2022 (Dev Box Compatible)

I've found that even if I tell it to execute a powershell command of just ls . it will hang if I select the Elevated without Run as System or uncheck both (User Context)

I end up having to run everything as System which causes problems for some tasks.

ARM template
{
    "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "name": {
            "defaultValue": "gh-53-repro",
            "type": "string"
        },
        "imageName": {
            "defaultValue": "gh-53-repro",
            "type": "string"
        },
        "location": {
            "defaultValue": "[resourceGroup().location]",
            "type": "string"
        },
        "imagePublisher": {
            "defaultValue": "microsoftvisualstudio",
            "type": "string"
        },
        "imageOffer": {
            "defaultValue": "visualstudioplustools",
            "type": "string"
        },
        "imageSku": {
            "defaultValue": "vs-2022-ent-general-win11-m365-gen2",
            "type": "string"
        },
        "version": {
            "defaultValue": "latest",
            "type": "string"
        },
        "vmSize": {
            "defaultValue": "Standard_B4ms",
            "type": "string"
        },
        "osDiskSizeGB": {
            "defaultValue": 128,
            "type": "int"
        },
        "userAssignedIdentities": {
            "defaultValue": [],
            "type": "array"
        },
        "managedImageResourceId": {
            "type": "string"
        },
        "userAssignedIdentityResourceId": {
            "type": "string"
        }
    },
    "variables": {},
    "resources": [
        {
            "type": "Microsoft.VirtualMachineImages/imageTemplates",
            "apiVersion": "2022-07-01",
            "dependsOn": [],
            "name": "[parameters('name')]",
            "location": "[parameters('location')]",
            "properties": {
                "vmProfile": {
                    "vmSize": "[parameters('vmSize')]",
                    "osDiskSizeGB": "[parameters('osDiskSizeGB')]",
                    "userAssignedIdentities": "[parameters('userAssignedIdentities')]"
                },
                "source": {
                    "type": "PlatformImage",
                    "publisher": "[parameters('imagePublisher')]",
                    "offer": "[parameters('imageOffer')]",
                    "sku": "[parameters('imageSku')]",
                    "version": "[parameters('version')]"
                },
                "distribute": [
                    {
                        "type": "ManagedImage",
                        "imageId": "[parameters('managedImageResourceId')]",
                        "location": "westus3",
                        "runOutputName": "runOutputManagedImage"
                    }
                ],
                "customize": [
                    {
                        "type": "PowerShell",
                        "name": "Elevated User Context",
                        "inline": [
                            "ls ."
                        ],
                        "runElevated": true,
                        "runAsSystem": false
                    },
                    {
                        "type": "PowerShell",
                        "name": "User Context",
                        "inline": [
                            "ls ."
                        ],
                        "runElevated": false,
                        "runAsSystem": false
                    }
                ]
            },
            "tags": {},
            "identity": {
                "type": "UserAssigned",
                "userAssignedIdentities": {
                    "[parameters('userAssignedIdentityResourceId')]": {}
                }
            }
        }
    ],
    "outputs": {}
}

Activity

  1. changed the title [-]Image Builder hangs when building template with 'Elevated' powershell script[/-] [+]Image Builder hangs when building template with anything other than System Elevated powershell script/command[/+] on Feb 5, 2024
  2. kaushganguly commented on Feb 15, 2024

    @kaushganguly

    I can concur! It was so frustrating to have the builds fail even with some basic powershell commands. I was trying with various configurations but finally what had to be updated is that I had to run the customizations as System. Running as Elevated seems to have no purpose in that case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions