当我将Log to EventHub操作添加到我的Incoming处理时,Microsoft提供的基本示例很有用,但我希望能够记录请求内容和内容长度。目前,我找不到本示例中使用的上下文或context.Request对象的任何文档或定义。
<log-to-eventhub logger-id ='logger-id'>
@( string.Join(",", DateTime.UtcNow, context.Deployment.ServiceName, context.RequestId, context.Request.IpAddress, context.Operation.Name))
</log-to-eventhub>
有人可以指点我这方面的文件,或者至少告诉我如何获取请求体的内容或体长?
答案 0 :(得分:5)
以下是如何获取身体的信息:
string inBody = context.Request.Body.As<string>(preserveContent: true);
有关详情,请参阅Context variable表格中的context
,context.Request
和IMessage
部分。