APIM
  • 31 Mar 2022
  • 1 Minute to read
  • Contributors
  • Dark
    Light
  • PDF

APIM

  • Dark
    Light
  • PDF

Policies in API Management

Consider a business scenario with different Azure services like APIM, Logic App, and Function App. Here APIM acts as a proxy for the complete integration in Azure and it is essential to track the APIM as well. Here comes the Policies in APIM.

Policies are a powerful capability of the APIM that allows the publisher to change the behavior of the API through configuration.

Policies are applied inside the gateway which sits between the API consumer and the managed API.

The gateway receives all requests and usually forwards them unaltered to the underlying API. However, a policy can apply changes to both the inbound request and outbound response.

Click here to know more about Policies in APIM

Instrumenting Policies to track APIM requests

Since the Business Activity Monitoring (BAM) supports the tracking using API Endpoint, users can leverage Send-Request Policy to send request to an API Endpoint,

Click here to know more about tracking Business Transactions using HTTP endpoint.

Below is the APIM Policy syntax to track a Stage using Business Activity Monitoring (BAM) Endpoint:

<send-request mode="new" response-variable-name="reponse" timeout="60" ignoreerror="true"> 
<set-url> BAM Host Endpoint </set-url> 

<set-method>POST</set-method> 

<set-header name="Content-Type" exists-action="override"> 
<value>application/json</value> 
</set-header> 

<set-header name="SL360-BusinessProcess" exists-action="append"> 
<value> Business Process Name </value> 
</set-header> 

<set-header name="SL360-Transaction" exists-action="append"> 
<value> Transaction Name </value> 
</set-header> 

<set-header name="SL360-Stage" exists-action="append"> 
<value> Stage Name </value> 
</set-header> 

<set-header name="SL360-StageStatus" exists-action="append"> 
<value> Success/Failure/InProgress </value> 
</set-header> 

<set-header name="SL360-ArchiveMessage" exists-action="append"> 
<value> true/false </value> 
</set-header> 

<set-header name="SL360-IsTransactionComplete" exists-action="append"> <value> true/false </value> 
</set-header> 

<set-body>@{  
return new JObject( new JProperty("MessageBody",context.Variables["YOUR_Data"]), 
new JProperty("MessageHeader", new JObject( new JProperty("Content-Type", "application/json") ).ToString()) ).ToString(); 
}</set-body> // Refer the BAM using HTTP Endpoint document to know more about request body syntax

</send-request>

Was this article helpful?