OS Provisioning for VM did not finish in the allotted time
Troubleshoot Task Runner provisioning failures that start when a custom image that references the latest image version is updated in Azure.
This article explains how to troubleshoot the OS Provisioning for VM did not finish in the allotted time error. You see this error when Task Runner provisioning suddenly fails for a custom image whose ResourceID uses latest instead of a specific image version.
In this article
Symptoms
All of the following are true:
- You added a custom image to your workspace, and its image ResourceID uses
latestinstead of a specific image version. - Task Runner provisioning with that custom image worked before but has suddenly stopped working.
- The Provision Task Runner task ends with an error similar to the following:
<timestamp>:GATEWAY: An error occurred while trying to provision VM with ComputerName: [<ComputerName>]
<timestamp>:GATEWAY: Error: [Long running operation failed with status 'Failed'. Additional Info:'OS Provisioning for VM '<VM-resource-name>' did not finish in the allotted time. The VM may still finish provisioning successfully. Please check provisioning state later. Also, make sure the image has been properly prepared (generalized).
* Instructions for Windows: https://learn.microsoft.com/azure/virtual-machines/windows/prepare-for-upload-vhd-image
* Instructions for Linux: https://learn.microsoft.com/azure/virtual-machines/linux/create-upload-generic
* If you are deploying more than 20 Virtual Machines concurrently, consider moving your custom image to shared image gallery. Please refer to https://aka.ms/movetosig for the same.']
<timestamp>:GATEWAY: ERROR Reason: Error occurred while trying to provision VM <timestamp>:GATEWAY: Agent Task Ended: Status:[Error], Name=[Provision Task Runner]
Cause
The most likely cause is that someone recently updated the image and published a new version, but Sysprep did not complete successfully on it. As a result, the new version is not properly generalized.
Because your custom image references latest, Task Runner provisioning picks up the new version automatically. This explains why provisioning stops working without any change to your workspace configuration.
Using latest in the image ResourceID means every new image version is used as soon as it is published. If a new version is faulty, all Task Runner provisioning that uses the custom image is affected.
Prerequisites
Before you start, make sure you have:
- Access to the Azure portal with permission to view the image, its versions, and its role assignments.
- Permission to create a virtual machine in Azure for testing.
- The image ResourceID configured for the custom image in your workspace.
Troubleshooting steps
Verify the image ResourceID
- Open the custom image settings in your workspace.
- Copy the image ResourceID.
- In the Azure portal, confirm that the image at that ResourceID still exists.
- Confirm that the ResourceID ends in
/versions/latestand points to the correct image definition.
Verify the Gateway's Managed Identity has the Reader role
The Gateway's Managed Identity needs the Reader role on the latest image version. It usually inherits this role from the image gallery.
- In the Azure portal, open the latest version of the image.
- Select Access control (IAM).
- Select Role assignments.
- Confirm that the Gateway's Managed Identity has the Reader role, either directly or inherited from the image gallery.
If the role is missing, assign the Reader role to the Gateway's Managed Identity at the image or image gallery level. New image versions then inherit it, see How To Add Custom Operating System Images for Change360 Task Runner Provisioning for more details.
Manually provision a VM from the latest image version
This test shows whether the latest image version can provision at all, outside of Task Runner provisioning.
The quickest way to do this is with the Create VM option on the image version in your image gallery, which opens the VM creation form with that image version already selected.
- In the Azure portal, open the Azure Compute Gallery that holds the custom image.
- Open the image definition used by your workspace.
- Find the latest image version and select Create VM next to it.
- On the Create a virtual machine page, confirm that the Image field shows the latest image version.
- Choose a Subscription, Resource group, Region and Size. The region must be one that the image version is replicated to.
- Enter the administrator account details and any other required settings, then select Review + create and Create.
- Check whether the VM finishes provisioning successfully.
If the deployment fails, open the deployment's details in the Azure portal and note the error message. It helps the team that maintains the image find the cause.
Delete the test VM when you finish so you don't incur unnecessary Azure costs.
Test provisioning with the previous image version
This test shows whether provisioning succeeds when you use the version before the latest one.
- In the Azure portal, open the Azure Compute Gallery that holds the custom image.
- Open the image definition used by your workspace.
- Sort by Published date.
- Select the version that was published prior to the latest version
- Copy the ResourceID of the previous image version from Settings → Properties under the image version.
- Add the previous image version to your workspace as a new custom image, using its specific version in the ResourceID, see How To Add Custom Operating System Images for Change360 Task Runner Provisioning for more details.
- Switch the OS for the affected environment to the new custom image for the previous version on the Manage Environments screen.
If there are any queued and/or running sequences you will not be able to change the configured Operating System until they have all completed.
- Do one of the following:
- Provision a debug Task Runner for the affected environment from the Task Runner Config screen.
- Rediscover an application that currently fails because of the provisioning error, if the affected environment is the Discovery OS.
- Check whether provisioning now succeeds.
Conclusion
The problem is with the latest image version if either of the following is true:
- Manually creating a VM in Azure from the latest image version also fails.
- Provisioning with the previous image version in your workspace succeeds.
In that case, the problem is not with how the custom image is configured in your workspace or with how the Task Runner is provisioned from it.
To resolve the issue, ask the team that maintains the image to check that the latest version was properly prepared and generalized with Sysprep before publishing.
Keep the affected environment set to the previous version custom image until a corrected image version is available, at which point you can update the environment to again use the existing custom image which uses latest in the ResourceID.