azure-powershell icon indicating copy to clipboard operation
azure-powershell copied to clipboard

Feature request: Add a -wait parameter to vm operations

Open trondhindenes opened this issue 11 years ago • 10 comments

Because of the limitation of cloudservices and one operation at a time, currently we have to build tons of error-checking into our scripts. This becomes ugly for scripts which run in parallell. Please add a "wait" parameter to the start/stop/set etc azurevm cmdlets so that we don't have to perform excessive error-handling/retries (essentially this would allow us to always wait for an operation which places a lock on the cloud service).

trondhindenes avatar Mar 25 '15 14:03 trondhindenes

Hey @trondhindenes are you proposing a design where a -Wait parameter takes time in seconds ?

singhkays avatar Jun 15 '15 23:06 singhkays

@singhkay I would have thought -Wait until the status of the VM changes. ie stop-azurevm -wait wouldn't return until the VM had actually been stopped.

Like @trondhindenes, some of my scripts have loops in them, that basically get-azurevm, check if the status has changed from provisioning to running, and then continue.

Having said all this, I'm currently migrating my deployment pipeline to ARM templates, and at least today, deploying a template will wait until the operation succeeds or fails.

mukaibot avatar Jul 12 '15 00:07 mukaibot

@singhkay I'm proposing a "-wait" switch param that will wait until the operation has actually been exectued and returned a result (such as create/delete vm, and start/stop vm).

trondhindenes avatar Jul 13 '15 06:07 trondhindenes

@singhkay @trondhindenes

Any time that you have a question about how a command should work, check out similar PowerShell core commands. For example, there is a command called Wait-Job that enables you to wait for PowerShell Background Jobs to complete.

You can specify that the command should wait on:

  • One or more jobs
  • A specific job state
  • A job by name
  • A job by ID
  • A job by instance ID

While Azure VM operations are not directly equivalent to PowerShell core commands, similar design principles should be used to ensure consistency, and comprehensive functionality.

Cheers, Trevor Sullivan Microsoft MVP: PowerShell

pcgeek86 avatar Jul 13 '15 15:07 pcgeek86

I agree that we should have a consistent way to do this.

New-AzureVM has a -WaitForBoot parameter that may address the need for creation, but I don't believe that any of the other commands do.

I don't think Wait-Job would matter as I don't think the items actually create any form of persistent running jobs; they issue the API call and return.

A behavior change that provides consistency would be welcome.

MattAllison avatar Jul 13 '15 15:07 MattAllison

IMHO all cmdlets should be syncrhonous bydefault, waiting for the requested operation to complete. For async operations, the -asjob along with the job cmdlets could be implemented.

trondhindenes avatar Jul 13 '15 16:07 trondhindenes

To recap: The proposed design is to implement a -Wait switch on the Start, Stop and Update-AzureVM cmdlets in ASM module?

singhkays avatar Jul 17 '15 19:07 singhkays

@singhkay Yes, this is scoped to Azure Service Management (ASM). I think the idea is that any operation on an IaaS VM in a Cloud Service, that would place a lock on the Cloud Service, should cause another operation to "wait" until it is completed. I'm guessing this would have to be achieved through long polling on the client (Azure PowerShell), but should be abstracted from the user as @trondhindenes indicates.

Cheers, Trevor Sullivan Microsoft MVP: PowerShell

pcgeek86 avatar Jul 17 '15 20:07 pcgeek86

@pcgeek86 I think the current commands do wait until the CS lock is released, but not until the operation completes. For example, a call to Stop a VM could complete in 2 minutes, but the VM may still be in the "Stopping" state for a few more minutes. Similar for starting and creating VMs.

I think the desired behavior is to ensure we have a mechanism to wait until the operation is completed (VM running/stopped/etc) before continuing.

MattAllison avatar Jul 17 '15 21:07 MattAllison

Sorry folks, will have to close this. This was brought up in SDK triage but didn't make the cut for investment due to resource constraints and the need to focus on investing in new RM cmdlet and improvements.

singhkays avatar Apr 25 '16 23:04 singhkays