Azure Service Bus Queue Trigger function does not collect my message in the queue after starting for a while

I have a service bus queue in Azure and a service bus queue trigger function. When I first publish a function and send a message to the service bus queue, the function starts and works fine.

But if I leave it alone and do not send any messages to the queue, say ~ 1 hour, and then send a message, the function does not start. I need to run the function again in the portal by clicking “run”, or I need to republish it to Azure.

How do I make it work, so I don’t need to restart it every hour or so ??? My application cannot send a new message to the queue for a couple of hours or even days.

FYI - I read here that the function is turned off after 5 minutes, I can’t use the functions, if so, and I don’t want to use the timer trigger, because then I will run the function more than I want, I spend money! Right? If my only, better choice is to start the timer function every 30 minutes during the day, I can just suck it up and do it, but I would prefer the function to execute when the message gets into the queue message.

FYI2 - ultimately I want to hide the message until a certain date when I first push it into the queue (for example, to display 1 week from the moment it is placed in the queue). What am I trying to do? I want to send an email to registered students after class, and a class can be assigned in 1-30 days. Therefore, when the class is planned, I do not want the function to run before the end of the class, which can be 1 week, 2 weeks 2 days, 3 weeks 3 days, etc. After the class was originally planned in my application.

Here is a snippet from a .json function

{ "generatedBy": "Microsoft.NET.Sdk.Functions-1.0.0.0", "configurationSource": "attributes", "bindings": [ { "type": "serviceBusTrigger", "connection": "Yogabandy2017_RootManageSharedAccessKey_SERVICEBUS", "queueName": "yogabandy2017", "accessRights": "listen", "name": "myQueueItem" } ], "disabled": false, "scriptFile": "..\\bin\\PostEventEmailFunction.dll", "entryPoint": "PostEventEmailFunction.Function1.Run" } 

Here is the function

 public static class Function1 { [FunctionName("Function1")] public static void Run([ServiceBusTrigger("yogabandy2017", AccessRights.Listen, Connection = "Yogabandy2017_RootManageSharedAccessKey_SERVICEBUS")]string myQueueItem, TraceWriter log) { log.Info($"C# ServiceBus queue trigger function processed message: {myQueueItem}"); } } 

I was asked to publish my payment plan

enter image description here

+5
source share
2 answers

I suspect that you are using scenarios 1 and 2 below, which will be disabled after a period of inactivity.

  • Functional Application in the Free Applications Plan . Always On is not available, so you can update your plan.

  • Functional Application application in the Basic / Standard / Premium Application Service Plan . You need to make sure that the Always On function is checked in the Application Settings function

  • If the Function app uses the Consumption Plan , this should work. It will awaken the app features for every request. For your scenario, I would recommend this approach as it only uses resources as needed.

FYI1. If you use the above work, you do not need a timer.

The consumption plan in the application settings will look like this: Azure Function Use Plan

+2
source

Please check your tariff plan for 1. Platform features 2. Application service plan 3. in the "Price level" section

Indicate the name of the application.

+1
source

Source: https://habr.com/ru/post/1273954/


All Articles