Azure continuous webjob (blob) triggering only once - azure

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.

Related

Azure blob triggered function only triggering on some blobs

I have two blob triggers which I want to trigger on. One works and one does not!
I use Azure Storage Explorer to make sure blobs are uploaded to each blob, scanFiles will never trigger, and scanExports seem to always trigger.
Question: What can cause some blobs to not trigger an Azure function?
[FunctionName("scanFiles")]
public static async Task FilesScan([BlobTrigger("files/{newBlobName}", Connection = "BlobConnectionstring")]CloudBlockBlob newBlob, string newBlobName, ILogger log, ExecutionContext context)
{
await VirusScan(newBlob, newBlobName, log, context);
}
[FunctionName("scanExports")]
public static async Task ExportsScan([BlobTrigger("exports/{newBlobName}", Connection = "BlobConnectionstring")]CloudBlockBlob newBlob, string newBlobName, ILogger log, ExecutionContext context)
{
await VirusScan(newBlob, newBlobName, log, context);
}
I found that the issue was because one of the blobs were considered High scale, which triggers this bug and also makes the host process kill itself when run locally (see this issue)

Disabled Azure Function Still Pulls Messages off of Azure Storage Queue

I have a basic QueueTrigger Azure function. When I disable the function in the azure portal it's still pulling messages off the storage queue (because when I look at the queue in the Azure Queue Storage Explorer the queue is empty and if i add a message it is immediately pulled off).
Here is the code:
[FunctionName("ProcessMessage")]
public static void Run([QueueTrigger("queue-name", Connection = "queue-connection")] Models.Message message, TraceWriter log)
{
log.Info($"C# Queue trigger function processed: {message}");
}
I noticed that when I stop the whole functions app it stops processing messages off the queue, but I was hoping that I could disable queue processing temporarily without stopping the whole function app. How does one do that?
Thanks!
Disabling the V1 function created in Visual Studio does not work in the azure portal. You should use the attribute:
https://learn.microsoft.com/en-us/azure/azure-functions/disable-function#functions-1x---c-class-libraries
(see important section)

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 Function: Http Trigger instead of Blob Trigger for more resilient operations

I have a scenario where I write some data to an azure storage blob, trigger an azure function to process the data, and write the result to another blob storage record. I've come across a weird scenarios where if the function hasn't triggered for a while(couple days) it will stop responding to the trigger unless I navigate to the azure portal and restart the function. This also happens when I use VSTS to publish the function in my CI/CD pipeline. Again, a restart is required.
To get around this, I would prefer to use an HTTP trigger where I can at least get a status code response to my request and have a better sense that my function has actually been triggered.
Here is the method for the blob trigger that is working:
[FunctionName("ProcessOpenOrders")]
public static async Task Run([BlobTrigger("%TriggerBlobPath%/{name}")]Stream myBlob, string name, TraceWriter traceWriter, [Blob("%OutboundBlobPath%/{name}", FileAccess.Write)] Stream outputStream, ExecutionContext context)
The TriggerBlobPath and OutboudBlobPath are slot setting configurations. This is important because I need the blob storage record name as a parameter so I know what to read and I use the same record name as the output.
For an HTTP trigger, I would need that name in a similar way. My question is how?
Something like this I'm guessing:
public static async Task Run([HttpTrigger] HttpRequestMessage request, [Blob("%InboundBlobPath%/{name}", FileAccess.Read)]Stream myBlob, string name, TraceWriter traceWriter, [Blob("%OutboundBlobPath%/{name}", FileAccess.Write)] Stream outputStream, ExecutionContext context)
but I get the following error:
Microsoft.Azure.WebJobs.Host: Unable to resolve binding parameter 'name'. Binding expressions must map to either a value provided by the trigger or a property of the value the trigger is bound to, or must be a system binding expression (e.g. sys.randguid, sys.utcnow, etc.).
If anyone knows how to implement an HttpTrigger in place of a blob trigger, but get the same functionality, that would be very helpful. Otherwise, if someone has an idea on how to guarantee that the blob trigger actually triggered, that would also be very helpful.
Thanks!
I think the official guidance is to use Event Grid trigger to react on blob events. See Reacting to Blob storage events and Event Grid trigger for Azure Functions.

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

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.

Resources