Skip to content

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

@brandonh-msft

Description

@brandonh-msft

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": {}
}

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