Enable Log Scrapping or Data Masking in Azure APIM for Request and Response Bodies

Sumit Gaur 390 Reputation points
2025-11-30T04:42:20.6233333+00:00

Hi,

We are using Azure API Management as our API Gateway to expose backend APIs to our customers. In some scenarios, clients send sensitive information such as credit card related data or user login details. For compliance and security reasons, we need to mask specific JSON fields within the request and response bodies before they are logged.

While reviewing the logger configuration, I noticed that data masking options are available for query parameters and HTTP headers, but there does not appear to be support for masking fields inside the request or response body.

Could you clarify whether Azure APIM provides any capability to mask or redact sensitive fields within request/response bodies in diagnostic logs or Application Insights? If not, is there a recommended approach to achieve this?

Links i have referenced :

https://learn.microsoft.com/en-us/azure/api-management/api-management-howto-app-insights?tabs=rest

https://learn.microsoft.com/en-us/rest/api/apimanagement/diagnostic/create-or-update?view=rest-apimanagement-2024-05-01&tabs=HTTP#datamaskingentity

Azure API Management
Azure API Management
An Azure service that provides a hybrid, multi-cloud management platform for APIs.
{count} votes

1 answer

Sort by: Most helpful
  1. Q&A Assist
    2025-11-30T04:42:32.7933333+00:00
    AI generated content. This question contains an answer created with AI from Q&A Assist. Learn more

    Azure API Management (APIM) does not currently provide built-in capabilities to mask or redact sensitive fields within the request and response bodies in diagnostic logs or Application Insights. While data masking options are available for query parameters and HTTP headers, there is no support for masking fields inside the request or response body.

    To achieve data masking for sensitive information in request and response bodies, you may need to implement a custom solution. This could involve:

    • Custom Policies: You can create policies in APIM that manipulate the request and response bodies. For example, you can use the set-body policy to modify the body content before it is logged or sent to the backend.
    • Middleware: If your backend APIs are under your control, consider implementing middleware that handles data masking before logging the request and response.
    • Application Insights Telemetry Processor: If you are using Application Insights, you can create a telemetry processor to filter or modify the telemetry data before it is sent to Application Insights.

    These approaches allow you to ensure that sensitive information is not logged or exposed in your diagnostic logs, thereby maintaining compliance and security.

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.