azure-cli: `az vm run-command invoke` returns Deployment Failure with message "Finished executing command"
Describe the bug
az vm run-command invoke -g $RSGROUP -n $VMNAME --command-id EnableRemotePS
returns error message:
Deployment failed. Correlation ID: 5ba9e28a-b1ae-4793-a2e3-0f48babe00c4. VM has reported a failure when processing extension 'RunCommandWindows'. Error message: "Finished executing command".
To Reproduce
- Create new VM.
- Attempt to enable PS remoting using Azure CLI
az vm run-command invoke -g $RSGROUP -n $VMNAME --command-id EnableRemotePS
- Observe error.
Expected behavior Either:
A) No erroneous deployment failure message B) (If actually failed) Better error message describing actual error.
Environment summary Azure Shell: Bash
azure-cli (2.0.42)
acr (2.1.0)
acs (2.2.0)
advisor (0.6.0)
ams (0.2.0)
appservice (0.2.0)
backup (1.2.0)
batch (3.3.0)
batchai (0.4.0)
billing (0.2.0)
cdn (0.1.0)
cloud (2.1.0)
cognitiveservices (0.2.0)
command-modules-nspkg (2.0.2)
configure (2.0.18)
consumption (0.4.0)
container (0.3.0)
core (2.0.42)
cosmosdb (0.2.0)
dla (0.2.0)
dls (0.1.0)
dms (0.1.0)
eventgrid (0.2.0)
eventhubs (0.2.0)
extension (0.2.0)
feedback (2.1.4)
find (0.2.12)
interactive (0.3.26)
iot (0.2.0)
keyvault (2.2.0)
lab (0.1.0)
maps (0.3.0)
monitor (0.2.0)
network (2.2.0)
nspkg (3.0.3)
policyinsights (0.1.0)
profile (2.1.0)
rdbms (0.3.0)
redis (0.3.0)
reservations (0.3.0)
resource (2.1.0)
role (2.1.0)
servicebus (0.2.0)
servicefabric (0.1.0)
sql (2.1.0)
storage (2.1.0)
vm (2.1.0)
Python location '/opt/az/bin/python3'
Extensions directory '/home/user/.azure/cliextensions'
Python (Linux) 3.6.1 (default, Jul 13 2018, 23:21:56)
[GCC 5.4.0 20160609]
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 18 (9 by maintainers)
@Drewm3 I don’t think you have adequately addressed this issue. I have encountered the same behavior as the original reporter. This isn’t a matter of getting the script to run, but instead a problem with retrieving error stream information from the script sent to the VM. The issue from what I can tell is that the script on the VM is not returning the stderr / stdout data back to the machine that invoked the az run-command. I don’t think this has anything to do with the user the account runs under. Perhaps the azure agent could be involved here in terms of permissions, but the key point is that the script neither aborts as expected nor pipes back the error when there are issues, despite the output claiming an error occurred.
All you have to do to reproduce this is send an <az vm run-command invoke --command-id RunPowerShellScript --scripts @myscript.ps1> command that has an error in the myscript.ps1 body and attempt to troubleshoot it as you normally would troubleshoot any other script. So far as I can tell, the only way to determine what the error was is to go here on the VM: C:\Packages\Plugins\Microsoft.CPlat.Core.RunCommandWindows\1.1.2\Status
I would recommend trying to push a script with errors and troubleshoot that without logging onto the VM. If you are able to do that in a manner that is straightforward, please pass that information along. Otherwise, as far as I can tell this needs improvement.
Hi,
I’m running the azure-cli (2.0.74) on a MacOs (10.14.6) and I’m getting the same error.
This is how I run:
I tested my
myscript.ps1
directly in the VM and it works fine.Any ideas?