Hi there,
we have an Azure Function App with a trigger from Service Bus. The issue is that all messages end up in the Dead Letter Queue rather than being delivered.
Function App
- written in JavaScript using v4 Programming Model
- uses connection string stored in environment variables
- no errors in App insights
- no invocations in Function App -> [App] -> Overview -> [function]
// File process-queue.js
app.serviceBusQueue('queueProcessJob', {
connection: 'SERVICE_BUS_CONNECTION_STRING',
autoComplete: true,
queueName: process.env.SERVICE_BUS_QUEUE_NAME,
handler: async (message, context) => {
context.info('[Process Job] Message received', message);
// We are using zod to validate the message
const parsedMessage = jobMessageSchema.safeParse(typeof message === 'string' ? JSON.parse(message) : message);
if (!parsedMessage.success) {
context.error('Service Bus Handler Function received invalid message', JSON.stringify(parsedMessage.error.issues, null, 2));
throw new Error('Invalid queue job message');
}
// We process the job here -> we are not calling CompleteMessageAsync or returning anything
}
});
-
SERVICE_BUS_CONNECTION_STRING
contains connection string in format Endpoint=sb://[resource-name].servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=[key]
taken from Service Bus -> Settings -> Shared Access Policies -> RootManageSharedAccessKey.
- Key has Manage, Send, and Listen claims
- Queue name is stored in
SERVICE_BUS_QUEUE_NAME
and the value is correct.
When I invoke the function directly, it processes the data without any error, which leads me to believe that the "processing" is not an issue, but the trigger is not fired at all.
Also there are no exceptions or traces in App Insights, I tried running following queries:
traces | where message contains "queueProcessJob"
and
exceptions
Service Bus
- created in the same "subscription" plan
- messages appear in Queue and then are moved to Dead-letter queue with reason
MaxDeliveryCountExceeded
- time to live = 86400000
- delivery count = 10
Questions
Is there a way to debug the trigger? Why is it not firing and immediately goes to Dead-letter?