Azure Deployment fails at the end because of `Restart-Computer` cmdlet at the end of the script.

Malla, Tilak 1 Reputation point
2022-07-28T14:14:20.033+00:00

Hello,
At the end, deployment errors out the following message. I have nothing to do after reboot, but VM should reboot so that the domain join could take effect.
Anybody has idea to work around; to put something in the script that it will take VM into Reboot yet deployment won't error out? Help is appreciated.

{"code":"DeploymentFailed","message":"At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/DeployOperations for usage details.","details":[{"code":"VMExtensionProvisioningError","message":"VM has reported a failure when processing extension 'custom-script-extension'. Error message: \"Command execution finished, but failed because it returned a non-zero exit code of: '1'. Command execution may have been interrupted by a VM restart\"\r\n\r\nMore information on troubleshooting is available at https://aka.ms/VMExtensionCSEWindowsTroubleshoot "}]}

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
8,235 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. dashanan13 930 Reputation points
    2023-05-23T16:27:26.65+00:00

    Hei @learner Thanks for reaching out to Microsoft QnA.
    Sorry for the delay in response.

    If this is a script then it is possible that the step before this execution leads to a restart and the execution starts before the VM recovers.

    The easiest way out of this would be to put a check that the VM is available, it is easy to do in powershell and azure cli script.

    Also you could use a Infra as a code solution like bicep or terraform to do this, these solutions are resilient.

    Please mark this as Answer , if it helped

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.