azure api 管理:有没有办法在入站策略中获取操作名称
azure api management: is there a way to get the operation name in the inbound policy
在操作的入站策略中,有没有办法通过使用某种表达式来获取操作名称?就像:在 C# 反射中获取方法名称。
is there a way to get the operation name by using some sort of expression?
是的。 log-to-eventhub 策略将指定格式的消息发送到由 Logger 实体定义的事件中心。顾名思义,该策略用于保存选定的请求或响应上下文信息以供在线或离线分析。
任何字符串都可以用作要在事件中心中记录的值。在此示例中,所有入站呼叫的 date and time
、deployment service name
、request id
、ip address
和 operation name
都记录到使用 contoso-logger
id.
<policies>
<inbound>
<log-to-eventhub logger-id ='contoso-logger'>
@( string.Join(",", DateTime.UtcNow, context.Deployment.ServiceName, context.RequestId, context.Request.IpAddress, context.Operation.Name) )
</log-to-eventhub>
</inbound>
<outbound>
</outbound>
</policies>
是的。只需使用 "context.Operation.Name"
例如在 "set header" 政策中
<set-header name="MyHeader" exists-action="override">
<value>@(context.Operation.Name)</value>
</set-header>
在操作的入站策略中,有没有办法通过使用某种表达式来获取操作名称?就像:在 C# 反射中获取方法名称。
is there a way to get the operation name by using some sort of expression?
是的。 log-to-eventhub 策略将指定格式的消息发送到由 Logger 实体定义的事件中心。顾名思义,该策略用于保存选定的请求或响应上下文信息以供在线或离线分析。
任何字符串都可以用作要在事件中心中记录的值。在此示例中,所有入站呼叫的 date and time
、deployment service name
、request id
、ip address
和 operation name
都记录到使用 contoso-logger
id.
<policies>
<inbound>
<log-to-eventhub logger-id ='contoso-logger'>
@( string.Join(",", DateTime.UtcNow, context.Deployment.ServiceName, context.RequestId, context.Request.IpAddress, context.Operation.Name) )
</log-to-eventhub>
</inbound>
<outbound>
</outbound>
</policies>
是的。只需使用 "context.Operation.Name"
例如在 "set header" 政策中
<set-header name="MyHeader" exists-action="override">
<value>@(context.Operation.Name)</value>
</set-header>