vfabing / AzureVm

Azure DevOps Pipelines extension for starting and stopping Azure VM
https://marketplace.visualstudio.com/items?itemName=vfabing.AzureVirtualMachineManagerTask
MIT License
3 stars 3 forks source link

Start when already running #12

Open bbakermmc opened 4 years ago

bbakermmc commented 4 years ago

Will this throw an error if the machine is already running? If it does can you add a another option to check machine state, so then we can do logic checking.

IE: We have some hosted and paid build servers, the self hosted ones dont always get alot of uses so in the pipeline we want to do something like If BuildServerXX is not on Turn it on, If there are no more pending Builds/Releases then turn it off, so not every job is turn on/turn off. We might also just auto schedule some to be on between 9-5 etc. So just looking for the flexibility here.

vfabing commented 4 years ago

Hi, thanks for your kind comment!

Azure actions are often idempotent, so if the VM is already started, it should not throw an exception.

I am afraid the AzureVm extension is quite simple and might not the best for your use case.

By the way If I had to implement what you described, I might have a look to the serverless jobs, calling an Azure Function which then would start the VM (I have written a blog post describing this workflow, using ACI instead of VMs). The stop VM could then be done in an Azure Function checking the Agent queue every 10 minutes or more ?

Tell me if this helped and if you need further information!

bbakermmc commented 4 years ago

I can do what I want in Pipelines if you had an option that would return back the running state as a 3rd option in drop down

vfabing commented 4 years ago

Hi, sorry for the delay.

I checked a little bit more in the technical details, this should be doable by updating the azure-arm-compute used in this extension, and by calling the get method.

Let me find some time to implement this, and in the mean time, feel free to submit a pull request if you want to have a look :)

Regards,