Skip to content
Get Started for Free

API Management

Azure API Management (APIM) is a fully managed service for publishing, securing, and analyzing APIs at scale. It acts as a gateway between clients and backend services, providing features such as rate limiting, policy enforcement, authentication, and developer portal integration. APIM is commonly used to expose internal services as managed APIs, implement API versioning, and monitor API usage across organizations. For more information, see What is Azure API Management?.

LocalStack for Azure provides a local environment for building and testing applications that make use of Azure API Management. The supported APIs are available on our API Coverage section, which provides information on the extent of API Management’s integration with LocalStack.

This guide walks you through creating an API Management service, adding an API, and registering a backend.

Launch LocalStack using your preferred method. For more information, see Introduction to LocalStack for Azure. Once the container is running, enable Azure CLI interception by running:

Terminal window
azlocal start-interception

This command points the az CLI away from the public Azure management REST API and toward the LocalStack for Azure emulator API. To revert this configuration, run:

Terminal window
azlocal stop-interception

This reconfigures the az CLI to send commands to the official Azure management REST API.

Create a resource group to hold all resources created in this guide:

Terminal window
az group create --name rg-apim-demo --location westeurope
Output
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-apim-demo",
"location": "eastus",
"name": "rg-apim-demo",
"properties": { "provisioningState": "Succeeded" },
"type": "Microsoft.Resources/resourceGroups"
}

Create an API Management instance in the Consumption tier:

Terminal window
az apim create \
--name my-apim \
--resource-group rg-apim-demo \
--location westeurope \
--sku-name Consumption \
--publisher-email admin@example.com \
--publisher-name "My Organization"
Output
{
"gatewayUrl": "https://my-apim.azure-api.net",
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-apim-demo/providers/Microsoft.ApiManagement/service/my-apim",
"location": "East US",
"name": "my-apim",
"provisioningState": "Succeeded",
"publisherEmail": "admin@example.com",
"publisherName": "My Organization",
"resourceGroup": "rg-apim-demo",
"sku": { "capacity": 0, "name": "Consumption" },
"type": "Microsoft.ApiManagement/service",
...
}

Retrieve the details of the service instance and list all instances in the resource group:

Terminal window
az apim show --name my-apim --resource-group rg-apim-demo
Output
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-apim-demo/providers/Microsoft.ApiManagement/service/my-apim",
"location": "East US",
"name": "my-apim",
"provisioningState": "Succeeded",
"publisherEmail": "admin@example.com",
"publisherName": "My Organization",
"resourceGroup": "rg-apim-demo",
"sku": { "capacity": 0, "name": "Consumption" },
"type": "Microsoft.ApiManagement/service"
...
}

Then list all API Management services in the resource group:

Terminal window
az apim list --resource-group rg-apim-demo
Output
[
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-apim-demo/providers/Microsoft.ApiManagement/service/my-apim",
"name": "my-apim",
"provisioningState": "Succeeded",
"resourceGroup": "rg-apim-demo",
"sku": { "capacity": 0, "name": "Consumption" },
"type": "Microsoft.ApiManagement/service"
}
]

Check whether the service name is globally available before creating:

Terminal window
az apim check-name --name my-apim
Output
{
"message": "",
"nameAvailable": true,
"reason": "Valid"
}

Create an API in API Management:

Terminal window
az apim api create \
--resource-group rg-apim-demo \
--service-name my-apim \
--api-id orders-api \
--path orders \
--display-name "Orders API" \
--protocols https
Output
{
"displayName": "Orders API",
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-apim-demo/providers/Microsoft.ApiManagement/service/my-apim/apis/orders-api",
"name": "orders-api",
"path": "orders",
"protocols": [
"https"
],
"subscriptionRequired": true,
...
}

Get the API:

Terminal window
az apim api show \
--resource-group rg-apim-demo \
--service-name my-apim \
--api-id orders-api
Output
{
"displayName": "Orders API",
"name": "orders-api",
"path": "orders",
"protocols": [
"https"
],
...
}

Create an operation on the API:

Terminal window
az apim api operation create \
--resource-group rg-apim-demo \
--service-name my-apim \
--api-id orders-api \
--operation-id get-orders \
--display-name "Get orders" \
--method GET \
--url-template "/orders"
Output
{
"displayName": "Get orders",
"method": "GET",
"name": "get-orders",
"type": "Microsoft.ApiManagement/service/apis/operations",
"urlTemplate": "/orders",
...
}

Update the operation and verify the change:

Terminal window
az apim api operation update \
--resource-group rg-apim-demo \
--service-name my-apim \
--api-id orders-api \
--operation-id get-orders \
--set displayName="Get all orders"
az apim api operation show \
--resource-group rg-apim-demo \
--service-name my-apim \
--api-id orders-api \
--operation-id get-orders
Output
{
"displayName": "Get all orders",
"method": "GET",
"name": "get-orders",
"urlTemplate": "/orders",
...
}
  • Full CRUD lifecycle: Create, read, update, and delete APIM service instances.
  • API management: Create, read, and delete API definitions within a service.
  • API operations: Register and retrieve API operation definitions.
  • Backend management: Define and manage backend service configurations.
  • API gateway management: Create and manage self-hosted API gateways.
  • API policies: Attach XML policy documents to APIs (stored but not evaluated).
  • Name availability check: Validate service name uniqueness via the checkNameAvailability action.
  • Service listing: List all APIM services in a subscription or resource group.
  • No gateway proxy: Incoming API calls are not proxied through LocalStack. The APIM gateway does not process requests, apply policies, or forward traffic to backends.
  • No policy evaluation: Inbound, outbound, and error policies are stored in the ARM model but are not executed.
  • No developer portal: The APIM developer portal and its OAuth/subscription flows are not emulated.
  • No subscription keys: API subscriptions and key-based authentication are not enforced.
  • No rate limiting or quotas: Throttling, quota, and cache policies have no effect.
  • Consumption plan only for creation: SKU differences between Developer, Basic, Standard, Premium, and Consumption tiers are not emulated.

Explore end-to-end examples in the LocalStack for Azure Samples repository.

OperationImplemented
Page 1 of 0
Was this page helpful?