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

Azure - Logging Request Details to EventHub from API Management

当我将 Log to EventHub 操作添加到我的传入处理时 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>

谁能给我指点这方面的文档,或者至少告诉我如何获取请求正文的内容或正文长度?

以下是获取正文的方法:

string inBody = context.Request.Body.As<string>(preserveContent: true); 

有关详细信息,请参阅 Context variable table 中的 contextcontext.RequestIMessage 部分。