Anthony
Anthony

Reputation: 1926

Logging when an Azure (Basic) Web App Exceeds Quotas

Running a basic, free Windows Azure Web application for testing purposes I often exceed the CPU Time (short) quota of 3 minutes.

For example, when trialling the image optimisation Nuget package AzureImageOptimizer which is implemented as a Web Job, the initial optimisation run exceeded the limit and stopped the server.

I notice these events are not being recorded in the Web App's Activity Log. Why?

Questions:

Bonus question:

Upvotes: 0

Views: 286

Answers (1)

Amor
Amor

Reputation: 8491

Are these events logged?

No. If an application in its usage exceeds the CPU (short), CPU (Day), or bandwidth quota then the application will be stopped until the quota re-sets. No log will be written to any place.

Is it because this is a Free Web App?

Both Free and Shared Plan have the resources limits.

Can the Web App be configured so that they are logged?

I also haven't found any way to do it.

Is there an alternative way to catch these events?

Since you are using WebJob, you could add a CancellationToken parameter in your function. If the Web App is stopped. The IsCancellationRequested property will be set to true before the function stopped.

public static void ProcessQueueMessage([QueueTrigger("myqueue")] string message, CancellationToken cancellationToken)
{
    Task.Run(new Action(longTimeJob), cancellationToken);
    while (true)
    {
        Thread.Sleep(1000);
        if (cancellationToken.IsCancellationRequested)
        {
            Console.WriteLine("The function has been Cancelled since the Web App is stopped!");
        }
    }
}

Here is the information I captured from Azure WebJobs Dashboard when the Web App is stopped.

[06/07/2017 07:52:53 > 9d3635: INFO] The function has been Cancelled since the Web App is stopped!
[06/07/2017 07:52:53 > 9d3635: ERR ] Thread was being aborted.
[06/07/2017 07:52:53 > 9d3635: SYS INFO] WebJob process was aborted
[06/07/2017 07:52:54 > 9d3635: SYS INFO] Status changed to Stopped

Upvotes: 1

Related Questions