Azure-docs: How does the Custom Script Extension know if my script failed, and does it gather any error information?

Created on 2 Dec 2018  Â·  4Comments  Â·  Source: MicrosoftDocs/azure-docs

Script failures are mentioned in this documentation.
How does the Custom Script Extension infrastructure know whether my script succeeded or not? Is it based on exit codes?
When it fails (and possibly when it succeeds), is the failure reason propagated anywhere? If so, from where? Does it look at the stdout/stderr of my script?

Thanks!


Document Details

⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

cxp product-question triaged virtual-machines-windowsvc

Most helpful comment

@yotauber to add to @jakaruna-MSFT response, if you deploy a custom script it is added to the Extensions section in the Azure Portal. You can select that custom script and find additional details about the failure or succession. It should be similar to what you find in the "C:\Packages\Plugins\Microsoft.Compute.CustomScriptExtension1.9.2\Status" without the need to actually login to the VM.

All 4 comments

Thanks for the question! We are investigating and will update you shortly.

@yotauber The command we give in "commandToExecute" is executed in command prompt. I tried couple of scenarios.

  • In the first scenario, I gave a non existent file in the file URI. In this case provisioning failed with the status "Failed to download all specified files. "
  • In the second scenario, I gave a PowerShell file in the URI with a non existent command in it. In this case, Provisioning succeeded but I was able to see the "command not found" exception on the stdout. The failure in PowerShell is not propagated to the command prompt. I think this happened because of the error code mismatch between the PowerShell and batch. Generally PowerShell's last exit code($?) will be "True" of "False". In both the cases batch exit code(echo %ERRORLEVEL%) is 0. I tried the same in local machine and got the same result. PowerShell also supports numeric error codes. We will use that in next scenario.
  • In the third scenario, I gave a script which fails with a numerical error code(500). I have a try catch block in the PowerShell script and exiting with a numerical error code in catch block. In this case the extension fails with the status "provisioning failed".

We can find logs in the default path "C:\Packages\Plugins\Microsoft.Compute.CustomScriptExtension1.9.2\Status"
Please let me know your comments.

@yotauber to add to @jakaruna-MSFT response, if you deploy a custom script it is added to the Extensions section in the Azure Portal. You can select that custom script and find additional details about the failure or succession. It should be similar to what you find in the "C:\Packages\Plugins\Microsoft.Compute.CustomScriptExtension1.9.2\Status" without the need to actually login to the VM.

Worked offline with the user.
User don't have access to the VM or Portal. User have access only to run ARM templates. User wanted to get the custom script output while executing the ARM templates. Right now, Custom script extension output can be found from the portal or from the VM. ARM template will show only the script passed or failed.
Closing this issue for now. Please reopen if further details are needed.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

varma31 picture varma31  Â·  3Comments

paulmarshall picture paulmarshall  Â·  3Comments

bdcoder2 picture bdcoder2  Â·  3Comments

jharbieh picture jharbieh  Â·  3Comments

spottedmahn picture spottedmahn  Â·  3Comments