14

I have tried many things but the only way I can force AzFn to understand the invocation has failed, is to throw an exception and not handle it. So, if I return an HttpResponseException, AzFn will consider the invocation as a success. That feels wrong.

catch (Exception ex)
    {
        logger.Error($"{nameof(ex)}: {ex.Message}", ex);
        response = req.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message, ex);

    }

This should produce an invocation marked as fail but it doesn't.

4

1 回答 1

19

从您的函数中抛出的任何异常都会将该函数标记为失败。在您上面的代码中,您正在吞噬异常,因此我们认为它是成功的。如果您改为重新抛出异常,该函数将被标记为失败。在这种情况下,我们将代表您自动退回 500。

我们不看HttpStatusCode你返回来确定函数是否成功,只看函数是否成功运行到完成,没有异常。如果您的函数能够返回响应,那么从我们的角度来看,它是成功的。

于 2017-03-14T15:29:09.090 回答