My Spring Cloud Function does not get triggered and does not print the contents of the trigger method when deployed to Azure, but works fine on my local machine

Terence Pinto 0 Reputation points
2024-08-07T17:48:18.5466667+00:00

{

"scriptFile" : "../process-topic-payment-0.0.1-SNAPSHOT.jar",

"entryPoint" : "ca.on.gov.osc.process_topic_payment.ProcessTopicPaymentApplication.run",

"bindings" : [ {

"type" : "serviceBusTrigger",

"direction" : "in",

"name" : "message",

"queueName" : "paymentqueue",

"connection" : "POC_SB_QUEUE_CONNECTION_KEY"

} ]

}

User's image

User's image

User's image

Azure Functions
Azure Functions

An Azure service that provides an event-driven serverless compute platform.

0 comments No comments

1 answer

Sort by: Most helpful
  1. Amira Bedhiafi 43,036 Reputation points MVP Volunteer Moderator
    2026-05-10T15:35:01.21+00:00

    Hello Terence !

    Thank you for posting on MS Learn Q&A.

    Your func is being triggered in Azure and the evidence is:

    Executing 'Functions.PaymentEventHandlerTrigger'

    and the same service bus message is retried with increasing DeliveryCount so the real issue is that the invocation doesn't finish and eventually hits:

    Timeout value of 00:30:00 exceeded

    I think your code is hanging before your custom logs are written.

    Message messageTest =
        (Message) AzureFunctionUtil.enhanceInputIfNecessary(message, context);
    

    For a normal Java Azure Function Service Bus trigger, you do not need this line since it can bind the message directly to a String.

    So try to test first with the simplest possible handler:

    @FunctionName("PaymentEventHandlerTrigger")
    public void run(
        @ServiceBusQueueTrigger(
            name = "message",
            queueName = "paymentqueue",
            connection = "POC_SB_QUEUE_CONNECTION_KEY"
        ) String message,
        final ExecutionContext context
    ) {
        context.getLogger().info("Entered PaymentEventHandlerTrigger");
        context.getLogger().info("Message body: " + message);
    }
    

    and add a log before and after the Spring adapter line if you still need it:

    context.getLogger().info("Before enhanceInputIfNecessary");
    Message messageTest =
        (Message) AzureFunctionUtil.enhanceInputIfNecessary(message, context);
    context.getLogger().info("After enhanceInputIfNecessary");
    

    If you only see the first log so the Spring adapter call is blocking.

    For Spring Cloud Function on Azure, you need to avoid mixing patterns. Either use a plain Azure Function handler with @ServiceBusQueueTrigger or follow the Spring Cloud Function adapter model properly.

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.