Azure Timer Trigger webjob: Function is being recognised but not being triggered - azure

I have an Azure timer trigger webjob, deployed in two different environments with two different storage accounts. The webjobs have been deployed for about two months now, and were running as expected for quite some time. However, for about a week now, the function is being recognised but not being executed.
Here is how the logs look:
Found the following functions:
ADFSchedulerWebJob.Functions.ProcessTimerMessage
Job host started
Nothing happens after the Job host is started, i.e., the function ProcessTimerMessage is not called/executed. This is how the function looks:
public static void ProcessTimerMessage([TimerTrigger("0 */2 * * * *", RunOnStartup = true)] TimerInfo info, TextWriter log)
{
//function logic
}
This is how the Main method looks like:
static void Main()
{
JobHostConfiguration config = new JobHostConfiguration();
config.UseTimers();
var host = new JobHost(config);
host.RunAndBlock();
}
The same is occurring even when I try to debug the webjob locally. What could be the possible reason/resolution?
Any help appreciated.

What could be the possible reason/resolution?
As Thoms mentioned that it seems that the same storage account is used for another webjob or others.
We could debug it with following ways:
1.Try to use another storage account
2.Check the webjob log from the storage
We could get more info about Webjob log from the blog.

Related

HTTP Request/Response on Azure WebJob

I'm looking to create a WebJob that takes in a request and sends a response, much like an Azure Function with an HTTP trigger. I want to use a WebJob instead because I need to use wkhtmltopdf, which cannot run on a Consumption plan, and we are already paying for an App Service that it can run on.
I know how to run the WebJob using an HTTP POST from this link: https://stackoverflow.com/a/42824776/443044.
What I cannot figure out is how to create the WebJob itself.
Here is my Program class:
public class Program
{
[NoAutomaticTrigger]
public static void TestMethod(TextWriter logger)
{
logger.WriteLine("TEST: " + req.Content.ToString());
}
// Please set the following connection strings in app.config for this WebJob to run:
// AzureWebJobsDashboard and AzureWebJobsStorage
static void Main()
{
var config = new JobHostConfiguration();
...
var host = new JobHost(config);
host.Call(typeof(Program).GetMethod("TestMethod"), null);
}
}
The program throws an exception if I try to give TestMethod the return type of HttpResponseMessage or a parameter of type HttpRequestMessage.
How can I achieve the request/response functionality like with an Azure Function?
we are already paying for an App Service -> You do realize you can host your azure function on an existing app plan as well? learn.microsoft.com/en-us/azure/azure-functions/….
But AFAIK webjobs do not have capabilities to respond to requests.

Is there a way to change the Azure function trigger type programmatically.

Looks like function.json in your Azure function's zip file defines Az func's trigger. Is it possible to change the trigger from Timer based to Event based programatically? Meaning, can I have a python application running perhaps in my local computer which calls Azure python sdk and says hey, change the Azure Function x's trigger from timer based to event hub based trigger and here is the additional event hub namespace name and connection string information that you need.
This is not possible.
However, I can think of the following workaround, which should accomplish the goal.
First, you can define multiple function triggers within one function project (one function app service). They could be bound to different targets. Something like this:
public static class Functions
{
[FunctionName("FunctionTimer")]
public static async Task RunAsync([TimerTrigger("%Schedule%")]TimerInfo myTimer, ILogger log)
{
if (!AppSettings.IsTimerTriggerActive)
return;
...
}
[FunctionName("FunctionEventHub")]
public static async Task RunAsync([EventHubTrigger("", Connection = "eventHubConnectionString")] EventData[] eventDataBatch, ILogger log)
{
if (!AppSettings.IsEventHubTriggerActive)
return;
...
}
}
You cannot enable/disable a function programmatically, but you can control which one of these is active via the App Service Application Settings. The latter could be managed through the Web App API: https://learn.microsoft.com/en-us/rest/api/appservice/webapps/updateapplicationsettings
Thus you can activate either trigger. One can even skip the (de)activation if that's compatible with the logic.

Azure Webjob Queue trigger not working

My queue trigger works only when the azure queue is being populated with messages and when simultaneously the webjob is running.(in my local dev environment)
But when i start the webjob (having the queue trigger) first , and then after a few seconds put new messages into the queue, the trigger doesn't detect them. Its like the trigger stops listening once there is no new messages. is this a normal behaviour for the trigger ? If not how do i resolve this issue ?
Main method :
static void Main()
{
InitializeQueue();
var config = new JobHostConfiguration();
if (config.IsDevelopment)
{
config.UseDevelopmentSettings();
}
var host = new JobHost();
// The following code ensures that the WebJob will be running continuously
host.RunAndBlock();
}
Function with queue trigger
public static void ProcessQueueMessage([QueueTrigger("myqueue")] CloudQueueMessage message)
{
Debug.Write(message.AsString);
}
For on-demand WebJobs, Azure has a configuration setting called WEBJOBS_IDLE_TIMEOUT that is denoted in seconds and defaults to two minutes.
If your on-demand WebJob isn’t triggered within the WEBJOBS_IDLE_TIMEOUT interval, Azure will kill your WebJob.
I recommend setting your Web App’s WEBJOBS_IDLE_TIMEOUT variable to a healthy number of seconds to prevent this from happening.
You can set this variable on the Web App’s Application Settings screen by adding it to the App Settings section of the Web App instance that is hosting your WebJob.

Azure Storage Queue WebJob never stops

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.
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).

Azure continuous webjob (blob) triggering only once

I have an Azure webjob that has a few blob triggered functions within. I uploaded this to Azure via the Add job dialog on the portal and set it to "Run Continuously" The behavior expected was that any time a blob is added /modified to the containers specified in the blob trigger the corresponding function be called. This however does not happen.
The only way to trigger the functions (after having uploaded blobs) is to Stop the web job and restart it again.
Every time I restart the job the functions
seem to be triggered and triggered only once. Any subsequent blob updates don’t seem to trigger them again.
On the portal however the WebJob shows as 'Running' however no functions get triggered after the initial trigger.
The main function for this web job looks like this :
static void Main()
{
var host = new JobHost();
host.RunAndBlock();
}
What could be the issue ?
The trigger functions are standard blob triggered functions and work for the first time - hence I am not yet sharing that code.
UPDATE
The function signature looks like this
public static void UpdateData([BlobTrigger("inputcontainer/{env}-update-{name}")] Stream input, string name, string env, TextWriter logger)
public static void DeleteData([BlobTrigger("inputcontainer/{env}-delete-{name}")] Stream input, string name, string env, TextWriter logger)
Because of how the blob triggers are implemented, it can take up to 10 minutes for the function to be invoked.
If the function is not triggered even after 10 minutes, please share with us the function signature and the names of blobs that you are uploading.

Resources