---
title: Blob Storage Policy-based Logging for Azure API Management Service APIs with Nodinite
description: Learn how to implement Blob Storage Policy-based Logging for Azure API Management Service APIs with Nodinite. Track all requests and responses, including payloads and headers, and enable robust monitoring and alerting.
---

# Blob Storage Policy

>[!IMPORTANT]
>**Azure Trusted Service Connectivity Retirement (March 2026)** - Microsoft is retiring the Trusted Services feature, which affects logging from APIM to Azure Blob Storage when network restrictions are enabled. Read the [Microsoft announcement](https://learn.microsoft.com/en-us/azure/api-management/breaking-changes/trusted-service-connectivity-retirement-march-2026)<sup>:fa-arrow-up-right-from-square:</sup> and review the [alternative solutions][Network Restrictions & Alternative Solutions].

>[!INFO]
>This guide explains how to apply a :Nodinite:-specific policy that enables comprehensive logging from the Azure API Management platform to :Nodinite:.

✅ Track all API requests and responses, including payloads and headers, with ease  
✅ Achieve [asynchronous][Asynchronous Logging], scalable logging for any payload size  
✅ Monitor and receive real-time alerts with :Nodinite: agents  
✅ Maintain compliance and traceability through end-to-end logging  

The diagram below shows the end-to-end flow for logging events from Azure API Management to Blob Storage and then to :Nodinite:.

<div class="mermaid">
graph LR
    subgraph "Payload (Any size)"
        AA[Azure API Management</br>with Policy 2] --> | 1. Log Event, </br>Any size | roBS[Blob Storage]  
    end
    subgraph "Nodinite"
        roBS --> C{Pickup Service}
        C --> F[Log API]
    end
</div>

*Diagram: End-to-end flow for logging API events from Azure API Management to Blob Storage and :Nodinite:.*

When you activate the **Blob Storage Policy**, the code running in the **Azure API Management** platform generates a :Nodinite:-specific [JSON Log Event][] and stores it in the Blob Storage Container. This approach captures every request and response, regardless of payload size, and ensures all relevant data remains available for monitoring and analysis.

>[!TIP]
>Use the :Nodinite: [Azure Monitoring Agent][Azure Agent] to receive alerts if [Log Events][Log Event] accumulate in Blob Storage. The :Nodinite: [Pickup Log Events Service Logging Agent][] consumes these [Log Events][Log Event]. You can also configure a backout container for malformed messages, ensuring you do not lose data and that all issues are monitored.

The :Nodinite: [Pickup Log Events Service Logging Agent][] processes [Log Events][Log Event] from Blob Storage asynchronously, providing scalable and reliable logging.

>[!TIP]
>The :Nodinite: [Non-Events Monitoring Agent][Non Events Agent] alerts you if the number of events deviates from expectations, helping you maintain operational integrity.

## Configuration Steps

Follow these steps to enable logging to :Nodinite: in your Azure API Management Service APIs:

* :fa-user-gear: Add and configure a [Managed Identity](#fa-user-gear-managed-identity)  
* Add and configure [Named Values](#named-values)  
* Add [Policy Fragments](#policy-fragments)  
  * [Inbound Policy Fragment](#inbound-policy-fragment)
  * [Outbound Policy Fragment](#outbound-policy-fragment)
  * [On-Error Policy Fragment](#on-error-policy-fragment)
* [Add a reference to Policy Fragments in **All APIs**](#add-a-reference-to-policy-fragments-in-all-apis)
  * [Inbound Processing](#inbound-processing)
    * [Inbound Policy Fragment](#inbound-policy-fragment-inbound-processing)
  * [Outbound Processing](#outbound-processing)
    * [Outbound Policy Fragment](#outbound-policy-fragment-outbound-processing)
  * [On-Error Processing](#on-error)
* [Variables](#variables)
  * [Set variable on **All operations**](#set-variable-on-all-operations)
  * [Set variables on the API level (inbound)](#set-variables-on-the-api-level-inbound)
  * [Set variables on the API level (outbound)](#set-variables-on-the-api-level-outbound)
  * [Set variables on the API level (on-error)](#set-variables-on-the-api-level-on-error)

Next, configure the :Nodinite: [Pickup Log Events Service Logging Agent][] to consume [Log Events][Log Event] from Blob Storage. Route malformed [Log Events][Log Event] to a backout container for further analysis.

Configure the :Nodinite: [Azure Monitoring Agent][Azure Agent] to ensure you do not stockpile [Log Events][Log Event] in your destination or backout containers.

Create and use :Nodinite: [Log Views][] with [Search Fields][] to provide business users and stakeholders with actionable insights into your logged data.

Optionally, set up the :Nodinite: [Non-Events Monitoring Agent][Non Events Agent] to validate that you receive the expected number of [Log Events][Log Event] during a given period.

____

## :fa-user-gear: Managed Identity

In the **Blob Storage Policy**, you use a user-assigned [Managed Identity](https://learn.microsoft.com/en-us/entra/identity/managed-identities-azure-resources/overview)<sup>:fa-arrow-up-right-from-square:</sup> to securely access Azure resources.

1. Create (or reuse) a Managed Identity in the [Azure Portal](https://portal.azure.com)<sup>:fa-arrow-up-right-from-square:</sup>.  
2. Note the Client ID; you will need it in the [Named Values](#named-values) section.  
  ![Managed Identity Client ID][1]  
   *Image: Managed Identity Client ID in Azure Portal.*  
3. Assign the **Storage Blob Contributor** role to the Managed Identity on the Storage Account referenced by the `logging-blob-url` named value.  
  ![Manage Identity - Storage Account][2]  
   *Image: Assigning Storage Blob Contributor role to Managed Identity.*  
4. Add the Managed Identity to the API Management Service where you will apply the **Blob Storage Policy**.  
  ![Managed Identity - APIM][7]  
   *Image: Adding Managed Identity to API Management Service.*

## Named Values

The **Blob Storage Policy** uses variables to avoid hard-coding values. You can expand the sample with additional properties as your business and policy require.

In the [Azure Portal](https://portal.azure.com)<sup>:fa-arrow-up-right-from-square:</sup>, navigate to the API Management Service and click **Named Values** in the sidebar.  
![Named Values][3]  
   *Image: Named Values configuration in Azure Portal.*  

Create the following named values:

1. `logging-blob-mid-client-id` – Enter the Client ID of the Managed Identity from the previous [step](#fa-user-gear-managed-identity).
2. `logging-blob-url` – Enter the URL for the Blob Storage Container. Ensure the value ends with a trailing slash (`/`). You can omit the trailing slash if you also change the code in the sample.  
  ![Blob Storage Container URL][4]  
   *Image: Blob Storage Container URL example.*  

## Policy Fragments

The **Blob Storage Policy** uses three Policy Fragments:

1. Inbound Policy Fragment – Creates a :Nodinite: [JSON Log Event][] for **Inbound Processing**.
2. Outbound Policy Fragment – Creates a :Nodinite: [JSON Log Event][] for **Outbound Processing**.
3. On Error Policy Fragment – Creates a :Nodinite: [JSON Log Event][] when an error occurs in **Inbound** or **Outbound Processing**.

>[!TIP]
>All events in the sample use the `x-ms-client-tracking-id` header value. This ID enables end-to-end logging and is vital for all :Nodinite: [Log Events][Log Event]. You can group all [Log Events][Log Event] for an interchange in a :Nodinite: [Log View][Log Views] by the built-in [Search Field][Search Fields] `Application interchange id`. If you call an Azure Function using the :Nodinite: [Serilog][] sinks, add this header to the context to retain the value through the whole chain of events. If you invoke a Logic App, the system handles this automatically.  
>![Group by Application interchange id][5]  
>*Image: Grouping by Application interchange id in Nodinite Log View.*

### Inbound Policy Fragment

1. In the [Azure Portal](https://portal.azure.com)<sup>:fa-arrow-up-right-from-square:</sup>, navigate to the API Management Service, then, in the sidebar, click **Policy Fragments**.
2. Create a new Policy Fragment and name it, for example, `InboundLoggingPolicyFragment`.  
  ![Policy Editor - Inbound Policy Fragment][6]  

|Property|Value|Comment|  
|---|---|---|  
|:fa-box-archive: [LogAgentValueId][Log Agents]|3|Once set, you should NOT change this value. Ensure it is not already in use before you start to log.|  
|:fa-diamond-turn-right: [EndPointDirection][Endpoint Directions]|10|Two-way Receive|  
|:fa-plug: [EndPointTypeId][EndpointTypes]|71|Microsoft Azure API Management|  
|:fa-arrows-left-right: [EventDirection][EventDirections]|21|ExternalIncomingRequest|  

*The fields are all part of a :Nodinite: [Log Event][].*

```xml
<fragment>
    <!-- Start Logging -->
    <set-header name="x-ms-client-tracking-id" exists-action="skip">
        <value>@(Guid.NewGuid().ToString())</value>
    </set-header>
    <set-variable name="correlationId" value="@{
            return context.Request.Headers.GetValueOrDefault("x-ms-client-tracking-id");
        }" />
    <send-request mode="new" timeout="20" response-variable-name="blobdata" ignore-error="true">
        <set-url>@($"{{logging-blob-url}}{Guid.NewGuid().ToString()}.json")</set-url>
        <set-method>PUT</set-method>
        <set-header name="x-ms-version" exists-action="override">
            <value>2019-07-07</value>
        </set-header>
        <set-header name="x-ms-blob-type" exists-action="override">
            <value>BlockBlob</value>
        </set-header>
        <set-body>@{
            var body = context.Request?.Body?.As<string>(preserveContent: true) ?? "";
            var bodyToLog = System.Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(body));

            var headers = context.Request.Headers.Where(h => !h.Key.Equals("authorization", StringComparison.InvariantCultureIgnoreCase) && !h.Key.Equals("ocp-apim-subscription-key", StringComparison.InvariantCultureIgnoreCase));
            var correlationId = context.Variables.GetValueOrDefault<string>("correlationId");

            Dictionary<string, string> contextProperties = new Dictionary<string, string>();
            contextProperties.Add("CorrelationId", correlationId);
        
            foreach (var h in headers) {
                contextProperties.Add(string.Format("Header#{0}", h.Key), String.Join(", ", h.Value));
            }
            
            var requestLogMessage = new {
                LogAgentValueId = 3,
                EndPointName = context.Api.Name + "/" + context.Operation.Name,
                EndPointUri = context.Deployment.ServiceName + "/" + context.Api.Name + "/" + context.Operation.Name,
                EndPointDirection = 10,
                EndPointTypeId = 71,
                EventDirection = 21,
                OriginalMessageTypeName = context.Variables.GetValueOrDefault<string>("loggingSchemaRoot", "UndeclaredSchemaRoot") + "#" + context.Variables.GetValueOrDefault<string>("loggingSchemaName", "UndeclaredSchemaName"),
                LogDateTime = DateTime.UtcNow,
                ApplicationInterchangeId = correlationId,
                Context = contextProperties,
                LogText = context.Variables.GetValueOrDefault<string>("logtext", ""),
                Body = bodyToLog
            };

            return JsonConvert.SerializeObject(requestLogMessage);
            }</set-body>
        <authentication-managed-identity client-id="{{logging-blob-mid-client-id}}" resource="https://storage.azure.com" />
    </send-request>
    <!-- End Logging -->
</fragment>
```

### Outbound Policy Fragment

|Property|Value|Comment|  
|---|---|---|  
|:fa-box-archive: [LogAgentValueId][Log Agents]|3|Once set, you should NOT change this value. Ensure it is not already in use before you start to log.|  
|:fa-diamond-turn-right: [EndPointDirection][Endpoint Directions]|10|Two-way Receive|  
|:fa-plug: [EndPointTypeId][EndpointTypes]|71|Microsoft Azure API Management|  
|:fa-arrows-left-right: [EventDirection][EventDirections]|25|ExternalIncomingResponse|  

```xml
<fragment>
    <!-- Start Logging -->
    <set-header name="x-ms-client-tracking-id" exists-action="skip">
        <value>@(Guid.NewGuid().ToString())</value>
    </set-header>
    <set-variable name="correlationId" value="@{
            return context.Response.Headers.GetValueOrDefault("x-ms-client-tracking-id");
        }" />
    <send-request mode="new" timeout="20" response-variable-name="blobdata" ignore-error="true">
        <set-url>@($"{{logging-blob-url}}{Guid.NewGuid().ToString()}.json")</set-url>
        <set-method>PUT</set-method>
        <set-header name="x-ms-version" exists-action="override">
            <value>2019-07-07</value>
        </set-header>
        <set-header name="x-ms-blob-type" exists-action="override">
            <value>BlockBlob</value>
        </set-header>
        <set-body>@{
            var body = context.Response?.Body?.As<string>(preserveContent: true) ?? "";
            var bodyToLog = System.Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(body));

            var headers = context.Response.Headers.Where(h => !h.Key.Equals("authorization", StringComparison.InvariantCultureIgnoreCase) && !h.Key.Equals("ocp-apim-subscription-key", StringComparison.InvariantCultureIgnoreCase));
            var correlationId = context.Variables.GetValueOrDefault<string>("correlationId");

            Dictionary<string, string> contextProperties = new Dictionary<string, string>();
            contextProperties.Add("CorrelationId", correlationId);
        
            foreach (var h in headers) {
                contextProperties.Add(string.Format("Header#{0}", h.Key), String.Join(", ", h.Value));
            }
            
            var requestLogMessage = new {
                LogAgentValueId = 3,
                EndPointName = context.Api.Name + "/" + context.Operation.Name,
                EndPointUri = context.Deployment.ServiceName + "/" + context.Api.Name + "/" + context.Operation.Name,
                EndPointDirection = 10,
                EndPointTypeId = 71,
                EventDirection = 25,
                OriginalMessageTypeName = context.Variables.GetValueOrDefault<string>("loggingSchemaRoot", "UndeclaredSchemaRoot") + "#" + context.Variables.GetValueOrDefault<string>("loggingSchemaName", "UndeclaredSchemaName"),
                LogDateTime = DateTime.UtcNow,
                ApplicationInterchangeId = correlationId,
                Context = contextProperties,
                LogText = context.Variables.GetValueOrDefault<string>("logtext", ""),
                Body = bodyToLog
            };

            return JsonConvert.SerializeObject(requestLogMessage);
            }</set-body>
        <authentication-managed-identity client-id="{{logging-blob-mid-client-id}}" resource="https://storage.azure.com" />
    </send-request>
    <!-- End Logging -->
</fragment>
```

### On-Error Policy Fragment

>[!NOTE]
>The [LogStatus][Log Status Codes] is set to `-1` to indicate an Error condition.

```xml
<fragment>
    <!-- Start Logging -->
    <set-header name="x-ms-client-tracking-id" exists-action="skip">
        <value>@(Guid.NewGuid().ToString())</value>
    </set-header>
    <set-variable name="correlationId" value="@{
            return context.Request.Headers.GetValueOrDefault("x-ms-client-tracking-id");
        }" />
    <send-request mode="new" timeout="20" response-variable-name="blobdata" ignore-error="true">
        <set-url>@($"{{logging-blob-url}}{Guid.NewGuid().ToString()}.json")</set-url>
        <set-method>PUT</set-method>
        <set-header name="x-ms-version" exists-action="override">
            <value>2019-07-07</value>
        </set-header>
        <set-header name="x-ms-blob-type" exists-action="override">
            <value>BlockBlob</value>
        </set-header>
        <set-body>@{
            var body = context.Request?.Body?.As<string>(preserveContent: true) ?? "";
            var bodyToLog = System.Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(body));

            var headers = context.Request.Headers.Where(h => !h.Key.Equals("authorization", StringComparison.InvariantCultureIgnoreCase) && !h.Key.Equals("ocp-apim-subscription-key", StringComparison.InvariantCultureIgnoreCase));
            var correlationId = context.Variables.GetValueOrDefault<string>("correlationId");

            Dictionary<string, string> contextProperties = new Dictionary<string, string>();
            contextProperties.Add("CorrelationId", correlationId);
        
            foreach (var h in headers) {
                contextProperties.Add(string.Format("Header#{0}", h.Key), String.Join(", ", h.Value));
            }
            
            var requestLogMessage = new {
                LogAgentValueId = 3,
                EndPointName = context.Api.Name + "/" + context.Operation.Name,
                EndPointUri = context.Deployment.ServiceName + "/" + context.Api.Name + "/" + context.Operation.Name,
                EndPointDirection = 10,
                EndPointTypeId = 71,
                EventDirection = 25,
                OriginalMessageTypeName = context.Variables.GetValueOrDefault<string>("loggingSchemaRoot", "UndeclaredSchemaRoot") + "#" + context.Variables.GetValueOrDefault<string>("loggingSchemaName", "UndeclaredSchemaName"),
                LogDateTime = DateTime.UtcNow,
                ApplicationInterchangeId = correlationId,
                Context = contextProperties,
                LogText = context.Variables.GetValueOrDefault<string>("logtext", ""),
                Body = bodyToLog,
                LogStatus = -1
            };

            return JsonConvert.SerializeObject(requestLogMessage);
            }</set-body>
        <authentication-managed-identity client-id="{{logging-blob-mid-client-id}}" resource="https://storage.azure.com" />
    </send-request>
    <!-- End Logging -->
</fragment>
```

## Add a reference to Policy Fragments in All APIs

In the [Azure Portal](https://portal.azure.com)<sup>:fa-arrow-up-right-from-square:</sup>, navigate to the API Management Service, then, in the sidebar, click **APIs**, then **All APIs**.  
![All APIs][8]  

### Inbound Processing

Use the [Inbound Policy Fragment](#inbound-policy-fragment) to create :Nodinite: [Log Events][Log Event] for the **Request**.

#### Inbound Policy Fragment (Inbound Processing)

1. Click on the **Add policy** button.  
    ![Inbound Policy Fragment (Inbound Processing)][9]  
2. Add a reference to the [Inbound Policy Fragment](#inbound-policy-fragment).

```xml
 <inbound>
    <include-fragment fragment-id="InboundLoggingPolicyFragment" />
</inbound>
```

### Outbound Processing

Use the [Outbound Policy Fragment](#outbound-policy-fragment) to create :Nodinite: [Log Events][Log Event] for the **Response**.

#### Outbound Policy Fragment (Outbound Processing)

1. Click on the **Add policy** button.  
    ![Outbound Policy Fragment (Outbound Processing)][12]  
2. Add a reference to the [Outbound Policy Fragment](#outbound-policy-fragment).

```xml
<outbound>
    <include-fragment fragment-id="outboundLoggingPolicyFragment" />
</outbound>
```

### On Error

Use the [On-Error Policy Fragment](#on-error-policy-fragment) to create :Nodinite: [Log Events][Log Event] when there is an **error**.

```xml
<on-error>
    <include-fragment fragment-id="onerrorLoggingPolicyFragment" />
</on-error>
```

### Complete example with all Policy Fragments

```xml
<policies>
    <inbound>
        <include-fragment fragment-id="InboundLoggingPolicyFragment" />
    </inbound>
    <backend>
        <forward-request />
    </backend>
    <outbound>
        <include-fragment fragment-id="outboundLoggingPolicyFragment" />
    </outbound>
    <on-error>
        <include-fragment fragment-id="onerrorLoggingPolicyFragment" />
    </on-error>
</policies>
```

## Variables

In the final steps with the **Blob Storage Policy**, you need to set a few values. These are commonly used to attribute the :Nodinite: [JSON Log Event]. You can develop additional dynamics based on the provided examples.

* [Set variable on **All operations**](#set-variable-on-all-operations)
* [Set variables on the API level (inbound)](#set-variables-on-the-api-level-inbound)
* [Set variables on the API level (outbound)](#set-variables-on-the-api-level-outbound)
* [Set variables on the API level (on-error)](#set-variables-on-the-api-level-on-error)

The following variables are part of the default :Nodinite: **Blob Storage Policy**:

|Variable|Default Value|Example|Comment|  
|---|---|---|---|  
|:fa-tags: `loggingSchemaRoot`|`UndeclaredSchemaRoot`|`Nodinite.Logging.Schemas`|The **prefix** part of the [Message Type][Message Types] name|  
|:fa-tags: `loggingSchemaName`|`UndeclaredSchemaName`|`Orders`|The **suffix** part of the [Message Type][Message Types] name. Should be set on individual operation level|  
|:fa-align-left: `logtext`|``|`Hello World`|Empty by default; Can be set on individual operation level|  

>[!INFO]
>Using the example values, the name of the [Message Type][Message Types] in the resulting :Nodinite: [JSON Log Event][] is `Nodinite.Logging.Schemas#Orders`. If possible, please use a **versioning scheme** in real-world scenarios, i.e. `Nodinite.Logging.Schemas/1.0#Orders`

In the [On-Error](#on-error-policy-fragment), the `LogStatus` is set to -1 (indicating an Error), this is a candidate you may be interested in setting as a variable. Feel free to modify the default Policy Fragments to fit your use case.

* [Log Status Codes][]

### Set variable on **All operations**

In the [Azure Portal](https://portal.azure.com)<sup>:fa-arrow-up-right-from-square:</sup>, navigate to the API Management Service. In the sidebar, click **APIs**, and then select one of the APIs, then **All operations**.  
![Set variable on All operations][10]

#### Complete example

Below is an example of setting the value for `loggingSchemaRoot` for all operations (inbound, outbound, and on-error). You can override the value if you want to on the operation level.

```xml
<policies>
    <!-- Throttle, authorize, validate, cache, or transform the requests -->
    <inbound>
        <set-variable name="loggingSchemaRoot" value="Nodinite.Logging.Schemas" />
        <base />
    </inbound>
    <!-- Control if and how the requests are forwarded to services  -->
    <backend>
        <base />
    </backend>
    <!-- Customize the responses -->
    <outbound>
        <set-variable name="loggingSchemaRoot" value="Nodinite.Logging.Schemas" />
        <base />
    </outbound>
    <!-- Handle exceptions and customize error responses  -->
    <on-error>
        <set-variable name="loggingSchemaRoot" value="Nodinite.Logging.Schemas" />
        <base />
    </on-error>
</policies>
```

### Set variables on the API level (inbound)

For a specific operation, for example, a `POST`, in the **inbound** processing step, you can set the **suffix** part of the [Message Type][Message Types] name as described in the [Variables](#variables) heading. Also, you can set a Log Text (a description field for the :Nodinite: [Log Event][])

```xml
 <inbound>
    <set-variable name="loggingSchemaName" value="Orders" />
    <set-variable name="logtext" value="Post OK" />
    <base />
    <set-backend-service id="apim-generated-policy" backend-id="nodinitefunctionapps" />
</inbound>
```

![Operation level - Inbound processing][11]  

### Set variables on the API level (outbound)

In the outbound processing step, we now make changes to the variables. You should set these values according to your business case and match the data in orbit.

```xml
 <outbound>
    <set-variable name="loggingSchemaName" value="OrderResponse" />
    <set-variable name="logtext" value="Response OK" />
    <base />
</outbound>
```

### Set variables on the API level (on-error)

In the on-error processing step, we again make changes to the variables. You should set these values according to your business case and match the data in orbit.

```xml
 <on-error>
    <set-variable name="loggingSchemaName" value="Error" />
    <set-variable name="logtext" value="Error in processing" />
    <base />
</on-error>
```

____

## Redacting Sensitive Data

>[!IMPORTANT]
>**Protect sensitive information in your logs** - By default, the policy examples exclude `Authorization` and `Ocp-Apim-Subscription-Key` headers to prevent logging credentials. Review your headers and request/response bodies to ensure no PII (Personally Identifiable Information), secrets, passwords, or API keys are logged.

### Best Practices

* :fa-filter: **Filter headers**: Exclude headers containing sensitive data (authentication tokens, API keys, secrets)
* :fa-eraser: **Redact body content**: Hash or remove PII fields from request/response bodies before logging
* :fa-list-check: **Use allowlists**: Log only known-safe headers instead of denylisting sensitive ones
* :fa-clipboard-check: **Audit regularly**: Review logged data to ensure compliance with data protection regulations

#### Example Header Filtering

```csharp
var headers = context.Request.Headers
    .Where(h => !h.Key.Equals("authorization", StringComparison.InvariantCultureIgnoreCase) 
             && !h.Key.Equals("ocp-apim-subscription-key", StringComparison.InvariantCultureIgnoreCase));
```

>[!TIP]
>APIM adds diagnostic headers such as `Ocp-Apim-Trace-AuthorizationExpired` to responses. These are captured by `context.Response.Headers` in the outbound section and will appear as context properties in :Nodinite: logs. See [APIM Troubleshooting][] if you want to understand or suppress them.

For advanced redaction techniques, custom body filtering, and security hardening options, see [Network Restrictions & Alternative Solutions - Redact Sensitive Data][Network Restrictions & Alternative Solutions].

____

## Network Restrictions & Troubleshooting

>[!IMPORTANT]
>**Are you experiencing issues with network-restricted Storage Accounts?** Due to Azure's Trusted Services retirement (March 2026), logging from APIM to Blob Storage with firewall restrictions requires alternative solutions. See our comprehensive guide: [Network Restrictions & Alternative Solutions][].

For the ports and hostnames to allow on each hop, see the [firewall settings for Azure API Management logging][APIM firewall].

**Quick summary of available options:**

1. **Private Endpoint with VNet Integration** ✅ Recommended - Best for production (requires Developer/Premium/Standard v2 tier)
2. **Direct [Log API Policy][]** - Works on all APIM tiers including Consumption
3. **Azure Function/Logic App Intermediary** - Flexible middle-ground solution
4. **Upgrade to Developer Tier** - Cost-effective option for dev/test (~$50/month)

👉 [Read the full troubleshooting guide][Network Restrictions & Alternative Solutions] for detailed implementation steps, pricing information, and recommendation matrix.

____

## :fa-hand-point-right: Next Steps

:fa-magnifying-glass-plus: [Search Fields][]  
:fa-search: [Log Views][]  

## :fa-link-horizontal: Related Topics

* :fa-cloud-arrow-down: [Logging with Azure API Management Services][Azure API Management Services - Logging]  
* :fa-file-code: [JSON Log Event][]  
* :fa-coins: [Reduce Azure API Management Logging Costs][]  

* [Event Hub Policy][]  
* [Log API Policy][]  

Interested in logging from other Azure Related Services?

* [Logging from Azure Logic Apps][LogicAppsAgent]  
* [Logging from Azure functions][Serilog]  

[1]:{ndm}/Documentation%20Pictures/LogAgent/AzureAPIMgmt/Blob/ManagedIdentityClientId.png
[2]:{ndm}/Documentation%20Pictures/LogAgent/AzureAPIMgmt/Blob/ManagedIdentityStorageAccount.png
[3]:{ndm}/Documentation%20Pictures/LogAgent/AzureAPIMgmt/Blob/NamedValues.png
[4]:{ndm}/Documentation%20Pictures/LogAgent/AzureAPIMgmt/Blob/BlobStorageURL.png
[5]:{ndm}/Documentation%20Pictures/LogAgent/AzureAPIMgmt/Blob/GroupByApplicationInterchangeID.png
[6]:{ndm}/Documentation%20Pictures/LogAgent/AzureAPIMgmt/Blob/InboundPolicyFragment.png
[7]:{ndm}/Documentation%20Pictures/LogAgent/AzureAPIMgmt/Blob/ManagedIdentityAPIM.png
[8]:{ndm}/Documentation%20Pictures/LogAgent/AzureAPIMgmt/Blob/AllAPIs.png
[9]:{ndm}/Documentation%20Pictures/LogAgent/AzureAPIMgmt/Blob/AllAPIsInboundPolicy.png
[10]:{ndm}/Documentation%20Pictures/LogAgent/AzureAPIMgmt/Blob/AllOperations.png
[11]:{ndm}/Documentation%20Pictures/LogAgent/AzureAPIMgmt/Blob/OperationInboundProcessing.png
[12]:{ndm}/Documentation%20Pictures/LogAgent/AzureAPIMgmt/Blob/AllAPIsOutboundPolicy.png

[APIM firewall]:{ndr}/Logging%20and%20Monitoring/Azure%20API%20Management/Overview.md#fa-shield-check-what-firewall-settings-are-required-for-azure-api-management-logging
[APIM Troubleshooting]:{ndr}/Logging%20and%20Monitoring/Azure%20API%20Management/Troubleshooting/Overview.md
[Asynchronous Logging]:{ndr}/Core%20Services/Log%20API/Features/Asynchronous%20Logging.md
[Azure Agent]:{ndr}/Logging%20and%20Monitoring/Azure/Overview.md
[Azure API Management Services - Logging]:{ndr}/Logging%20and%20Monitoring/Azure%20API%20Management/Overview.md
[Endpoint Directions]:{ndr}/Core%20Services/Log%20Event/Features/Endpoint%20Directions.md
[EndpointTypes]:{ndr}/Core%20Services/Log%20Event/Features/Endpoint%20Types.md
[Event Hub Policy]:{ndr}/Logging%20and%20Monitoring/Azure%20API%20Management/Policy/Event%20Hub.md
[EventDirections]:{ndr}/Core%20Services/Log%20Event/Features/Event%20Directions.md
[JSON Log Event]:{ndr}/Core%20Services/Log%20Event/Features/JSON%20Log%20Event.md
[Log Agents]:{ndr}/Administration/1.%20Log%20Management/3.%20Log%20Agents/Features/What%20is%20a%20Log%20Agent.md
[Log API Policy]:{ndr}/Logging%20and%20Monitoring/Azure%20API%20Management/Policy/Log%20API.md
[Log Event]:{ndr}/Core%20Services/Log%20Event/Overview.md
[Log Status Codes]:{ndr}/Administration/1.%20Log%20Management/3.%20Log%20Agents/Features/What%20is%20a%20Log%20Status%20Code.md
[Log Views]:{ndr}/Administration/1.%20Log%20Management/1.%20Log%20Views/Features/What%20is%20a%20Log%20View.md
[LogicAppsAgent]:{ndr}/Logging%20and%20Monitoring/Azure%20Logic%20Apps/Overview.md
[Message Types]:{ndr}/Repository%20Model/Message%20Types/Overview.md
[Network Restrictions & Alternative Solutions]:{ndr}/Logging%20and%20Monitoring/Azure%20API%20Management/Policy/Network%20Restrictions.md
[Non Events Agent]:{ndr}/Logging%20and%20Monitoring/Non-Events/Overview.md
[Pickup Log Events Service Logging Agent]:{ndr}/Logging%20and%20Monitoring/Pickup%20LogEvents%20Service/Overview.md
[Reduce Azure API Management Logging Costs]:{ndr}/Logging%20and%20Monitoring/Azure%20API%20Management/Troubleshooting/Reduce%20Azure%20API%20Management%20Logging%20Costs.md
[Search Fields]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/What%20is%20a%20Search%20Field.md
[Serilog]:{ndr}/Logging%20and%20Monitoring/Serilog/Overview.md