0

I have an Azure Function App that is triggered by Service Bus queue and writes the output to a storage account (blob storage).

The app works correctly when there are no errors. The output response object is correctly passed to the blob storage account through output bindings when no error is thrown by the application.

const index: AzureFunction = async function (
  context: Context,
  policyId: string
): Promise<void> {
  try {
    response = await app(policyId);
    context.log(
      "ServiceBus queue trigger function processed message",
      policyId
    );
    context.log("Blob outputted to: renewals/{DateTime}.json}");
    context.bindings.myOutputBlob = response;
  } catch (e) {
    context.bindings.myOutputBlob = {"status": "failed"};
    context.log("Blob outputted to: renewals/{DateTime}.json}");
    throw "some message";
  }
};

Let's say, the application throws an error. I want to catch the error and send the response to blob storage through context.bindings and then throw an Error so that the application can be retried again (max. 10 times before the message moves to the Dead Letter Queue).

For some reason, the application does not write to the Blob Storage account 10 times (not even once). Why is this happening?

What is an alternative approach to writing to the storage account and throwing an error at the same time?

  • 1
    I think you have to choose between output bindings and error handling; output bindings are only run on success. What I do is use the SDK to write errors explicitly and then do error handling; I don't use output bindings to write errors. – Stephen Cleary Apr 23 '23 at 12:15

0 Answers0