I have the following code:
[FunctionName("myFunc")]
public static void Run([ServiceBusTrigger("myQueue", Connection = "ConnectionString")]string myQueueItem, ILogger log)
{
log.LogInformation($"C# ServiceBus queue trigger function processed message: {myQueueItem}");
}
It is published in an Azure Function App that has Managed Identity configured to a namespace. The app shows no executions (no messages have been sent to the queue/namespace):
Yet, at the same time the namespace shows it has received requests:
The namespace has no other queues and NOTHING else connects/accesses/requests the namespace and queue. Also, if the function app is stopped the requests stop, as well.
I'm trying to figure out why would the function app send requests to the namespace (and so many) when it wasn't even triggered.
At least one reason that I can think of is that it could be monitoring the queue length.
Azure Functions will auto-scale up/down based on the number of messages in the queue after all.
Related
We have a Service Bus Queue; we are thinking to handle messages through Service Bus Queue Trigger in the Azure Function. But we want to consume bulk messages (in a loop) instead of re-triggering Function App for each message. What should be the way to achieve this and by using which handler. Should Azure Function be only used or we can host an App Service for consuming the same.
You should use batches. Simply declare the variable as an array.
public static class ProcessOrders
{
[FunctionName("ProcessOrders")]
public static void Run(
[ServiceBusTrigger("orders", Connection = "ServiceBusConnection")]
Message[] orders, // <-- array
ILogger log)
{
log.LogInformation($"Number of orders: {orders.Length}");
}
}
You can further configure batch size and such using the host.json file.
I have a queue in a service bus. After putting a message into a queue an azure logic app and an azure functions should betriggered and process the content.
My Azure logic app is triggered but my azure funcction is not triggered. My code for azure function:
[FunctionName("ReadMEssageFromQueue")]
public static void Run([ServiceBusTrigger("messagequeue", Connection = "AzureWebJobsStorage")]string myQueueItem, ILogger log)
{
log.LogInformation($"C# ServiceBus queue trigger function processed message: {myQueueItem}");
}
host json:
{
"IsEncrypted": false,
"Values": {
"FUNCTIONS_WORKER_RUNTIME": "dotnet",
"AzureWebJobsStorage": "******" // connection string of my service bus
}
}
should I set something in service bus queue to send message to both ressources?
Azure Service Bus Queue messages are picked up by only one processor. So I think in your case, the logic app is picking up and consuming the message first and the message is not available for the function to process. You can try temporarily disabling the logic app and letting function pick the message to confirm this.
Ref: azure-service-bus-queue-with-multiple-listeners
You can trigger the Azure function from your logic app (not sure if it'll help your use case), or you can use Azure Service Bus topics as topics support the model where multiple consumers can subscribe to a topic.
The former option might be a better approach for you from cost perspective, as you'd need to use Standard tier of service bus in order to use topics feature, which means additional cost for you over your current setup.
Also, you might want to use some other name for service bus connection string as AzureWebJobsStorage is used for storage account connection string
I have an Azure function with the following signature:
[FunctionName("MyFunction")]
[return: EventHub("eventhubname", Connection = "EVENTHUB_OUTPUT_CONNECTIONSTRING")]
public static string Run([IoTHubTrigger("messages/events", Connection = "IOTHUB_CONNECTIONSTRING", ConsumerGroup = "consumergroup")] EventData message, ILogger log)
I am running another Azure Functions with HTTP trigger. When i post to this function, it sends a device message to IoThub. I can see the message coming into the IoT Hub.
My routes have been setup as follows:
My routes have no special queries and i can see them hitting all the endpoints.
I have used the connectionstring from this page:
When i run in debug and when published to Azure, my function does not trigger when sending device messages. I have created 2 consumer groups and I am running 2 partitions.
Any idea what i could change to make this work?
this is how my azure function code looks like..
[FunctionName("Function1")]
public static void Run([ServiceBusTrigger("myqueue/$DeadLetterQueue", Connection = "ServiceBusConnection")]Message myQueueItem, ILogger log, int deliveryCount,
string messageId,
string deadLetterSource,
System.Collections.Generic.IDictionary<string, object> UserProperties
)
{}
I am able to get deadletter messages, but somehow not receiving regular messages from the service bus queue,
Is this expected behaviour?
if so how can i receive regular/deadletter messages in the same function.
I am using function 2.0 runtime.
Azure Function does not support receiving from more than a single source.
A queue and its dead-letter queue are considered two different queues.
You will need to have two Functions with some shared logic.
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)