.net-core - AZURE API 管理 - 对象引用未设置为对象的实例
问题描述
Azure API 管理带有响应“System.NullReferenceException:对象引用未设置为对象的实例”。
MyFunction.cs:line 61 中的 MyFunction.Run(HttpRequest req, ILogger log)
方法签名
公共异步任务运行([HttpTrigger(AuthorizationLevel.Anonymous,“get”,Route = null)] HttpRequest req,ILogger 日志)
对不起大家,我是 Azure APIM 的新成员!
当我将以下请求正文中的 JSON 发送到 c# azure function API 时,一切正常!!
{
"Id":40,
"status":"Doing",
"startedDateTime":"2019-10-17T17:50:44.1314885Z"
}
但是,当我通过 Azure API 管理将其发送到无服务器 Azure 函数 API 微服务时,我收到错误消息“对象引用未设置为对象的实例”。
我的 Azure 函数在标头中只有 APIM 密钥,没有其他内容;我刚刚创建了 APIM 消耗以用作端点,我只有 CORS 策略并尝试用于测试,但我遇到了同样的问题
<policies>
<inbound>
<base />
<choose>
<when condition="@(context.Request.Body != null)">
<set-body template="liquid">
<value>@(context.Request.Body.As<JObject>(preserveContent: true).Value<string>())</value>
</set-body>
</when>
</choose>
</inbound>
<backend>
<base />
</backend>
<outbound>
<base />
</outbound>
<on-error>
<base />
</on-error>
</policies>
有人可以帮助我吗?相同的解决方案是什么?
解决方案
推荐阅读
- powershell - 获取 VersionInfo 的子类型
- html - 如何在同一行的主要 div 之后留下次要 div?
- python - 在 python 中使用套接字的基本网络服务器
- javascript - 在 Localhost 上使用 XMLHttpRequest 进行文件上传不会触发 PHP 脚本
- css - 是否可以仅使用 CSS 选择元素的绝对最后一个孙子?
- c# - Visual Studio 2019 中的每个项目是否有启用“淡化未使用的使用”和“删除和排序使用”的设置?
- python - 作为线程执行的 Python 异步和同步函数
- azure-functions - Azure Durable Functions 扇出缩放行为不如预期
- bash - 在 MATLAB 中,如何将 Unix 标准输出存储在单元格数组中以进行多行命令?
- r - spark_apply 无法运行程序“Rscript”:在目录“C:\Users\username\AppData\Local\spark\spark-2.3.3-bin-hadoop2.7\tmp\local\spark-..\userFiles