Spring boot azure function : Http Trigger : This function was programmatically called via the host APIs return 500 error

Kapila Roshan Bogahapitiya 0 Reputation points
2024-06-15T11:39:59.12+00:00

I am trying to create a spring boot azure function using the following guide

https://github.com/eggboy/springcloud-azurefunction/tree/springboot3

https://medium.com/microsoftazure/create-azure-function-with-spring-cloud-function-ab150216d2bd

I was able to successfully build and run the azure function on local.

but when I try to deploy and trigger the http endpoint, I am getting HTTP 500 . Could someone help understand what is going wrong here.

Although in logs it says 200 return, on browser and postman it is getting HTPT 500

2024

https://xxx/api/getUserFunction?userId=abc

Error seen from browser

I am expecting successful return HTTP 200 response by the azure http trigger via both browser and postman, but both fails to with 500 error. But on local it works and return the expected result with HTTP 200

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,100 questions
Azure Spring Apps
Azure Spring Apps
An Azure platform as a service for running Spring Boot applications at cloud scale. Previously known as Azure Spring Cloud.
126 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Kapila Roshan Bogahapitiya 0 Reputation points
    2024-06-15T11:41:48.3966667+00:00

    Here are the logs

    2024-06-15T04:10:37Z   [Information]   Executing 'Functions.getUserFunction' (Reason='This function was programmatically called via the host APIs.', Id=57887aec-5989-45c1-bb34-453059bc2c5b)
    2024-06-15T04:10:37Z   [Verbose]   Sending invocation id: '57887aec-5989-45c1-bb34-453059bc2c5b
    2024-06-15T04:10:37Z   [Verbose]   Posting invocation id:57887aec-5989-45c1-bb34-453059bc2c5b on workerId:18a329dc-7f2e-4e0b-8487-c67d912b9eea
    2024-06-15T04:10:37Z   [Error]   Executed 'Functions.getUserFunction' (Failed, Id=57887aec-5989-45c1-bb34-453059bc2c5b, Duration=5ms)
    2024-06-15T04:10:37Z   [Verbose]   [HostMonitor] Checking worker statuses (Count=1)
    2024-06-15T04:10:37Z   [Verbose]   [HostMonitor] Worker status: ID=18a329dc-7f2e-4e0b-8487-c67d912b9eea, Latency=1ms
    2024-06-15T04:10:37Z   [Verbose]   [HostMonitor] Host process CPU stats (PID 68): History=(0,0,0,0,1), AvgCpuLoad=0.2, MaxCpuLoad=1
    2024-06-15T04:10:37Z   [Verbose]   [HostMonitor] Host process CPU stats (PID 26): History=(2,3,2,2,3), AvgCpuLoad=2, MaxCpuLoad=3
    2024-06-15T04:10:37Z   [Verbose]   [HostMonitor] Host aggregate CPU load 3
    2024-06-15T04:10:37Z   [Information]   Executing StatusCodeResult, setting HTTP status code 200
    2024-06-15T04:10:39Z   [Verbose]   Request successfully matched the route with name 'getUserFunction' and template 'api/getUserFunction'
    2024-06-15T04:10:39Z   [Information]   Executing 'Functions.getUserFunction' (Reason='This function was programmatically called via the host APIs.', Id=8d7fe07c-108e-4f3b-886e-8a95750737b8)
    2024-06-15T04:10:39Z   [Verbose]   Sending invocation id: '8d7fe07c-108e-4f3b-886e-8a95750737b8
    2024-06-15T04:10:39Z   [Verbose]   Posting invocation id:8d7fe07c-108e-4f3b-886e-8a95750737b8 on workerId:18a329dc-7f2e-4e0b-8487-c67d912b9eea
    2024-06-15T04:10:39Z   [Error]   Executed 'Functions.getUserFunction' (Failed, Id=8d7fe07c-108e-4f3b-886e-8a95750737b8, Duration=5ms)
    2024-06-15T04:10:41Z   [Verbose]   Request successfully matched the route with name 'getUserFunction' and template 'api/getUserFunction'
    2024-06-15T04:10:41Z   [Information]   Executing 'Functions.getUserFunction' (Reason='This function was programmatically called via the host APIs.', Id=7fba93bb-0744-4af3-8bb3-a604b8a5c4bd)
    2024-06-15T04:10:41Z   [Verbose]   Sending invocation id: '7fba93bb-0744-4af3-8bb3-a604b8a5c4bd
    2024-06-15T04:10:41Z   [Verbose]   Posting invocation id:7fba93bb-0744-4af3-8bb3-a604b8a5c4bd on workerId:18a329dc-7f2e-4e0b-8487-c67d912b9eea
    2024-06-15T04:10:41Z   [Error]   Executed 'Functions.getUserFunction' (Failed, Id=7fba93bb-0744-4af3-8bb3-a604b8a5c4bd, Duration=7ms)
    
    0 comments No comments

Your answer

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