azure - BadRequestObjectResult 不向客户端返回详细的错误消息

标签 azure azure-functions azure-functions-runtime

我有一个带有 HTTP 触发器的 Azure 函数。当未指定输入值时,它会生成 400 响应:

if (string.IsNullOrEmpty(artistName))
{
    return new BadRequestObjectResult("Artist name not specified.");
}

当函数在本地运行时(func host start)并且API调用不正确(我使用的是curl -X POST ...),出现上述错误显示消息。

当部署到 Azure 并以类似的方式调用时(而不是详细的错误消息),仅返回 Bad Request

为什么?
我怎样才能改变这种行为?

最佳答案

HttpTrigger 无法正确返回响应内容,这是函数运行时 2.0.11888 的一个已知问题。

如果您想解决此问题,请转到“应用程序设置”,将您的 FUNCTIONS_EXTENSION_VERSION 固定到以前的运行时 2.0.11857-alpha,直到新版本发布。

参见Azure Functions Runtime 2.0.11888 Preview .

更新

此问题已从 2.0.11933 修复.

关于azure - BadRequestObjectResult 不向客户端返回详细的错误消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51221375/

相关文章:

Azure 服务总线等效项?

azure - 在 Azure Active Directory 中使用自定义 OnPremisesSecurityIdentifier 修改或创建用户

azure - Azure Function App 中 SendGrid 绑定(bind)的目的

c# - 如何使用 C# 脚本 (csx) 从函数内获取 Azure 函数名称

Azure Functions - 始终开启和 HTTP 触发器

azure - 通过带有机器学习 Azure 数据的仪表板提供支持

azure - SQL Azure - 如何每晚恢复演示数据库?

用于文件迁移的 Azure 逻辑应用

Python Azure 函数、EventGrid 触发器

Azure Functions - 事件中心不触发函数