Function app EventhubTriggered Java, retries and failure

413 Views Asked by At

I am currently working in the Azure function app in java. Here is the scenario:

  1. The function app is EventHubTriggered
  2. Function app calls the endpoint (HTTPUrlConnection)
  3. It gets the response back

Now, if the response is 200 OK then it's fine, else, I'd want to fail the function app so that the Eventhub can retry to trigger this function app.

I was wondering what should the function app do(the method for EventHub trigger is void). Should I throw an exception for it to fail? If yes, then what exception would it be?

1

There are 1 best solutions below

0
On

Any exception thrown from your function will mark the function as failed.

It does not consider HttpStatusCode you return to determine if the function is successful, only whether the function ran successfully to completion without exception. If your function is able to return a response, it is successful from our point of view.

A retry policy can be defined for a specific function. See Retry policies (preview) and Azure Event Hubs output binding for Azure Functions