0

I have an WebApp running on Azure, the purpose of the WebApp is to process jobs from an Azure Storage Queue. It is set to Always On. The problem is that when I stop the WebApp in the Azure management portal the job doesn't actually stop.

I instantiated the job like:

class Program
    {
        static void Main()
        {
                string connectionString = ConfigurationManager.ConnectionStrings["StorageConnectionString"].ConnectionString;

                JobHostConfiguration config = new JobHostConfiguration(connectionString);
                config.NameResolver = new QueueNameResolver();

                JobHost host = new JobHost(config);

                // The following code ensures that the WebJob will be running continuously
                host.RunAndBlock();
        }
    }

The function that processes the queue is:

public static void ProcessQueueMessage([QueueTrigger("%apilogeventqueue%")] CloudQueueMessage messageEnvelope, TextWriter log, CancellationToken token)
{

}

I have trace logging so I can see the job never actually gets stopped.

mathewc
  • 13,312
  • 2
  • 45
  • 53
keitn
  • 1,288
  • 2
  • 19
  • 43
  • To make things even worse when I navigate to the WebJobs tab and look at the logs for the web job I can actually see the job is active yet I've changed Always on to false and stopped the WebApp – keitn Sep 08 '15 at 11:31

1 Answers1

1

WebJobs run under a special SCM (source control management) site of the host WebApp. When you stop the WebApp in the portal this SCM portion of the WebApp continues to run, because it supplies management capabilities to the WebApp that need to be available even when stopped.

To stop a WebJob from running, you can disable it in the portal UI by right clicking on the job in the jobs list and choosing "Stop". You can also stop ALL jobs in the WebApp by setting the WEBJOBS_STOPPED app setting to 1 (details here).

mathewc
  • 13,312
  • 2
  • 45
  • 53