Reputation: 13
In the inbound policy of an operation, is there a way to get the operation name by using some sort of expression? just like: in c# reflection get method name.
Upvotes: 1
Views: 1968
Reputation: 21
Yes. Just use "context.Operation.Name"
For example in a "set header" policy
<set-header name="MyHeader" exists-action="override">
<value>@(context.Operation.Name)</value>
</set-header>
Upvotes: 2
Reputation: 20097
is there a way to get the operation name by using some sort of expression?
Yes. The log-to-eventhub policy sends messages in the specified format to an Event Hub defined by a Logger entity. As its name implies, the policy is used for saving selected request or response context information for online or offline analysis.
Any string can be used as the value to be logged in Event Hubs. In this example the date and time
, deployment service name
, request id
, ip address
, and operation name
for all inbound calls are logged to the event hub Logger registered with the 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>
Upvotes: 1