|
| 1 | +--- |
| 2 | +title: How to front a network security perimeter-protected Azure resource with Azure API Management |
| 3 | +description: Step-by-step guidance to secure an Azure service backend with a network security perimeter and access it via Azure API Management using managed identity. |
| 4 | +ms.service: api-management |
| 5 | +ms.topic: how-to |
| 6 | +ms.date: 01/22/2026 |
| 7 | +author: dlepow |
| 8 | +ms.author: danlep |
| 9 | +ai-usage: ai-assisted |
| 10 | +--- |
| 11 | + |
| 12 | +# How to front a network security perimeter-protected Azure resource with Azure API Management |
| 13 | + |
| 14 | +This article shows how to secure an Azure service resource with a network security perimeter and access it through Azure API Management. You'll configure an Azure Storage account with a network security perimeter to allow traffic from your subscription (containing the API Management instance), use API Management's managed identity to authenticate to Azure Storage, and verify access with the API Management test console. |
| 15 | + |
| 16 | +For background concepts and terminology, see [What is a network security perimeter?](/azure/private-link/network-security-perimeter-concepts). |
| 17 | + |
| 18 | +## Why use a network security perimeter with API Management? |
| 19 | + |
| 20 | +Beginning March 2026, [API Management is retiring trusted service connectivity](/breaking-changes/trusted-service-connectivity-retirement-march-2026.md) from the gateway to select backend Azure services. If those backends such as Azure storage accounts rely on trusted Microsoft services or resource instances for network access, you must migrate. A network security perimeter provides the supported, centralized perimeter to explicitly allow traffic while keeping public access disabled. |
| 21 | + |
| 22 | +- **Modern token trust model:** Managed identity tokens now include trust mode claims that no longer permit implicit network bypass. A network security perimeter establishes the explicit network path your backend requires. |
| 23 | +- **Centralized governance:** A network security perimeter consolidates per‑service network rules into a single perimeter, improving consistency and observability across protected resources. |
| 24 | +- **Works without a virtual network:** For API Management instances not integrated with a virtual network, network security perimeter enables secure access by subscription or IP range. If virtual network integration is available and preferred, you can continue to use that approach. |
| 25 | + |
| 26 | +## Prerequisites |
| 27 | + |
| 28 | +- An Azure subscription and Owner or Contributor permissions. |
| 29 | +- An Azure API Management instance with system-assigned managed identity enabled. |
| 30 | +- An Azure Storage account with a container and at least one test blob (for example, a JSON file). |
| 31 | + |
| 32 | + To begin, enable public network access to the storage account. By default, this setting also enables trusted Microsoft services and resource instances to access the storage account. You modify access later when associating the network security perimeter. |
| 33 | + |
| 34 | +## Overview of steps |
| 35 | + |
| 36 | +1. Configure API Management to call Azure Storage using a managed identity. |
| 37 | +1. Create a network security perimeter profile and associate the storage account. |
| 38 | +1. Add an inbound access rule to allow API Management traffic (by subscription). |
| 39 | +1. Test the API call from API Management to confirm access with network security perimeter. |
| 40 | +1. Move network security perimeter access mode from **Transition** to **Enforced**. |
| 41 | + |
| 42 | +## Step 1. Configure API Management to call Azure Storage by using managed identity |
| 43 | + |
| 44 | +Configure API Management to call Azure Storage. Add a test API and operation, and configure a policy to authenticate by using API Management's managed identity. |
| 45 | + |
| 46 | +1. In the [Azure portal](https://portal.azure.com/), go to your API Management instance. |
| 47 | +1. Ensure system-assigned managed identity is enabled: |
| 48 | + 1. In the left menu, select **Security** > **Managed identities**. |
| 49 | + 1. On the **System assigned** tab, set **Status** to **On**. Select **Save**. |
| 50 | +1. Go to the storage account and grant the managed identity access: |
| 51 | + 1. In the left menu, select **Access control (IAM)** > **Add role assignment**. |
| 52 | + 1. Select **Storage Blob Data Reader** role (or **Contributor**, if write access is required) and assign to the API Management managed identity. |
| 53 | + 1. Complete the role assignment steps. |
| 54 | + |
| 55 | +### Configure an API operation to call Azure Storage |
| 56 | + |
| 57 | +1. Add an example API that fronts the Azure Storage blob URI (for example, `https://<storage-account-name>.blob.core.windows.net/apimtest`). |
| 58 | +1. Add a GET operation targeting the container. |
| 59 | + :::image type="content" source="media/using-network-security-perimeter/api-operation.png" alt-text="Screenshot showing a sample API operation to access a blob container in the portal."::: |
| 60 | + |
| 61 | +1. On the **Design** tab, select the operation and then select the policy editor (`</>`). Edit the operation's policy definition to add the API version header and managed identity authentication. Example: |
| 62 | + |
| 63 | +```xml |
| 64 | +<policies> |
| 65 | + <inbound> |
| 66 | + <base /> |
| 67 | + <!-- Authenticate to Storage using API Management managed identity --> |
| 68 | + <authentication-managed-identity resource="https://storage.azure.com/" /> |
| 69 | + <!-- Set Storage API version header --> |
| 70 | + <set-header name="x-ms-version" exists-action="override"> |
| 71 | + <value>2025-11-05</value> |
| 72 | + </set-header> |
| 73 | + </inbound> |
| 74 | + <backend> |
| 75 | + <forward-request /> |
| 76 | + </backend> |
| 77 | + <outbound> |
| 78 | + <base /> |
| 79 | + </outbound> |
| 80 | + <on-error> |
| 81 | + <base /> |
| 82 | + </on-error> |
| 83 | +</policies> |
| 84 | +``` |
| 85 | + |
| 86 | +> [!NOTE] |
| 87 | +> - The `resource` value should be `https://storage.azure.com/` for Azure Storage. |
| 88 | +> - Ensure the managed identity is assigned the appropriate RBAC role. |
| 89 | +
|
| 90 | +### Test the API operation |
| 91 | + |
| 92 | +Before configuring the network security perimeter, test that the API operation can reach the storage account. |
| 93 | + |
| 94 | +1. In API Management, open your API operation that calls Azure Storage: |
| 95 | + 1. In the left menu, under **APIs**, select your API and operation. |
| 96 | + 1. Select the **Test** tab. |
| 97 | + 1. Select **Test** and call the operation. Optionally select **Trace** to capture detailed telemetry. |
| 98 | + |
| 99 | +Expected results: |
| 100 | + - The call succeeds with a `200 OK` response and returns the blob content. |
| 101 | + - If you enabled **Trace**, you can verify that API Management added the managed identity token to the Authorization header. |
| 102 | + |
| 103 | +> [!TIP] |
| 104 | +> If you disable public network access on the storage account before configuring the network security perimeter, the call fails with a `403 Forbidden` response. |
| 105 | +
|
| 106 | +## Step 2. Create a network security perimeter profile and associate the storage account |
| 107 | + |
| 108 | +1. In the Azure portal, search for **Network Security Perimeters** and select it. |
| 109 | +1. Select **+ Create** and provide a name and region. Accept the defaults for other settings. |
| 110 | +1. Select **Review + create** and then **Create**. |
| 111 | +1. After deployment, configure the network security perimeter profile: |
| 112 | + 1. In the left menu, select **Settings** > **Associated resources** > **+ Add** > **Associate resources with an existing profile**. |
| 113 | + 1. Select the profile you created. Select **+ Add**. |
| 114 | + 1. Select the storage account that the API Management gateway is accessing. |
| 115 | + 1. Select **Associate**. |
| 116 | + |
| 117 | +## Step 3. Add an inbound access rule to allow API Management traffic |
| 118 | + |
| 119 | +To allow API Management to reach the storage account through the perimeter, add an inbound rule. The simplest approach is by subscription. |
| 120 | + |
| 121 | +1. In the Azure portal, go to your network security perimeter. |
| 122 | +1. In the left menu of the network security perimeter, select **Settings** > **Profiles**, then select the profile you created. |
| 123 | +1. In the left menu, select **Settings** > **Inbound access rules** > **+ Add**: |
| 124 | + 1. Enter a name for the rule. |
| 125 | + 1. Select **Source type** *Subscriptions*, then in **Allowed sources** select the subscription that contains your API Management instance. |
| 126 | +1. Select **Add**. |
| 127 | + |
| 128 | +> [!NOTE] |
| 129 | +> If you select IP address-based control, specify API Management's outbound public IP address range in the inbound rule. Ensure you include all outbound IP addresses for your API Management instance. |
| 130 | +> |
| 131 | +
|
| 132 | +### Confirm the network configuration in the storage account |
| 133 | + |
| 134 | +1. In the Azure portal, go to your Azure Storage account. |
| 135 | +1. In the left menu, under **Security + networking**, select **Networking**. |
| 136 | +1. On the **Public access** tab, select **Manage**. **Disable** public network access. |
| 137 | +1. Under **Network security perimeter**, confirm that the storage account is associated with your network security perimeter profile and that the access rule is listed. |
| 138 | + :::image type="content" source="media/using-network-security-perimeter/public-access-settings.png" alt-text="Screenshot of public access settings in the storage account in the portal."::: |
| 139 | + |
| 140 | +## Step 4. Test access from API Management |
| 141 | + |
| 142 | +1. In API Management, open your API operation that calls Azure Storage: |
| 143 | + 1. In the left menu, under **APIs**, select your API and operation. |
| 144 | + 1. Select the **Test** tab. |
| 145 | + 1. Select **Test** and call the operation. Optionally select **Trace** to capture detailed telemetry. |
| 146 | + |
| 147 | +Expected result: |
| 148 | + - The call succeeds with a `200 OK` response and returns the blob content. |
| 149 | + |
| 150 | +## Step 5. Move access mode to enforced |
| 151 | + |
| 152 | +A network security perimeter supports the following [access modes](/azure/private-link/network-security-perimeter-transition): |
| 153 | + |
| 154 | +- **Transition:** Applies both existing per-resource network settings and network security perimeter rules. This mode is the default when you first associate a resource. |
| 155 | +- **Enforced:** Applies only network security perimeter rules. Use this mode once you validate access. |
| 156 | + |
| 157 | +After you validate access in **Transition** mode, set the network security perimeter's access mode to **Enforced**. For more information, see [Steps to configure publicNetworkAccess and accessMode properties](/azure/private-link/network-security-perimeter-transition#steps-to-configure-publicnetworkaccess-and-accessmode-properties). |
| 158 | + |
| 159 | + |
| 160 | +## Related content |
| 161 | + |
| 162 | +- Learn more about [network security perimeter concepts and capabilities](/azure/private-link/network-security-perimeter-concepts) |
| 163 | +- [Networking options in API Management](virtual-network-concepts.md) |
0 commit comments