Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
brandonh-msft opened this issue Jan 29, 2024 · 1 comment

Comments

@brandonh-msft
Copy link
Member

brandonh-msft commented Jan 29, 2024

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": {}
}
@brandonh-msft brandonh-msft 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 Feb 5, 2024
@kgangulyvibe
Copy link

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants