[BUG] RunPowerShellScript execution hangs while deprovisioning Linux VM with waagent
See original GitHub issueRunPowerShellScript hangs while executing ‘sudo waagent -deprovision+user -force’
I want to be able to deprovision a VM from Azure Runbook. I’m using PowerShell as follows:
$restUri = 'https://management.azure.com/subscriptions/'+ $azContext.Subscription.Id+'/resourceGroups/'+$resourceGroupName+ `
'/providers/Microsoft.Compute/virtualMachines/'+$VMName+'/runCommand?api-version=2017-03-30'
$body = @{
'commandId' = 'RunShellScript'
'script' = @('sudo waagent -deprovision+user -force')
}
$response = Invoke-webrequest -Uri $restUri -Method Post -Headers $authHeader -Body $($body | ConvertTo-Json)
$asyncstatus = $($response.headers.'Azure-AsyncOperation')
$status = "InProgress"
While($status -eq "InProgress")`
{
Write-Output "Status: $status"
$response = invoke-webrequest -uri $asyncstatus -Headers $authHeader
$status = $($response.Content | ConvertFrom-Json).status -eq "InProgress"
sleep 5
}
Write-Output $($response.Content | ConvertFrom-Json).properties.output.message
Observed behavior: the user is deprovisioned, but the REST API call never completes so I keep getting “InProgress” every 5 seconds until the Runbook token times out. Expected behavior: the REST API call completes once the user is deprovisioned.
Note: same call (‘sudo waagent -deprovision+user -force’) completes OK when run via SSH.
- Distro and Version: Ubuntu 18.04 LTS
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
Run scripts in a Windows VM in Azure using action Run ...
This article describes how to run PowerShell scripts within an Azure Windows virtual machine by using the Run Command feature.
Read more >Azure Run Command for Dummies - Mandiant
On Windows, the RunPowerShellScript command executes PowerShell on the virtual machine as the SYSTEM user. On Linux, the RunShellScript command ...
Read more >How to remotely start service on Azure VM with powershell 5.1
When i run from Azure portal via "Run Command" - it hangs. When i run from the VM itself - it says: "Service...
Read more >Test | PDF | Virtual Machine | Microsoft Azure - Scribd
If your intent is to work with Linux VMs, look at Azure and Linux. ... If an error arises during self-service maintenance, the...
Read more >How to Run scripts on Azure Virtual Machines with the Run ...
To do so, select the VM and Run command. From here select a pre-created operation or RunPowerShellScript / RunShellScript. 1.png. Enter the ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@o-l-a-v you are correct - thank you for pointing out
@abaymar Yes, agreed. We have a work item for this in our queue, but at this point we are focused on other tasks. Once we get to it I’ll post to #1792