Azure - 从API管理向EventHub记录请求详细信息

Mr_*_*oad 4 azure azure-api-management azure-eventhub

当我将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>
Run Code Online (Sandbox Code Playgroud)

有人可以请指出我的文档,或者至少告诉我如何获取请求体的内容或体长?

Mik*_*kov 5

这是你如何获得身体:

string inBody = context.Request.Body.As<string>(preserveContent: true); 
Run Code Online (Sandbox Code Playgroud)

有关更多信息,请参阅Context变量表中的和context,context.Request以及IMessage各部分.