0

Ok Azure Experts,

  • I have a task that only needs to run once every week - this is a long running task that can take 2-3 days to run.

  • I have set up a worker role to scale based on a queue. On the day that we want the task to start - we populate the queue (using a Web Job).

  • During the rest of the time, when the queue is empty, I want the worker roles to shut down - but I cannot scale down to 0 instances.

  • Originally, we wanted to do this with a Web Job, but the website shuts down from time to time - abruptly turning off my webjob - is this supposed to happen? Even with Keep-Alive turned on? Also, you cannot stop a triggered Web Job from running - so if we want the process to stop - we need to turn off the Web site - not ideal.

How do I scale my instances down to zero?

* Alternatives solutions are also welcome.

Trying to minimize cost here - why pay for a worker role that isn't doing anything?

Simcha Khabinsky
  • 1,970
  • 2
  • 19
  • 34
  • Hi Simcha, is your WebSite with the WebJob in the Standard Tier and Set to AlwaysOn? If not, your WebSite will shut down in idle mode and boots up when being accessed. Then your WebJob won't run anymore. – wuerzelchen Nov 10 '16 at 12:45

1 Answers1

0

It is not possible to scale-down a Worker Role to 0 instances at this time. Even if you STOP the worker role, you're still incurring charges for STOPPED instances.

However, behavior that you're looking for, is possible with Virtual Machines. If you shutdown (STOP & DEALLOCATE) a virtual machine, you're not paying fees for that machine.

Now, the only challenge is to stop/start the VM based on a queue count. I don't recall if Azure portal's native scaling supports scaling down to 0 instances for VMs. However, if you use AzureWatch, you should be able to get this done without any issues. Disclaimer: I am affiliated with AzureWatch.

HTH

Igorek
  • 15,716
  • 3
  • 54
  • 92
  • Thanks. BTW, You do not have to do this with AzureWatch. You can shut down a VM using automated scripts. – Simcha Khabinsky Oct 28 '14 at 17:56
  • Sure, kicking off a powershell script to start a VM is simple. However, doing it only when a queue has stuff in it is harder, as you need to have something that monitors the queue and you need to host this powershell somewhere to run. But definately doable – Igorek Oct 28 '14 at 18:00
  • I think you can do this using Azure Automation Run Books straight from Azure Portal - but you're right looking at Queues from there might be more complex... back to topic, is there really no way to automate a process and only be charged when it's running? – Simcha Khabinsky Oct 28 '14 at 18:37