Overview
This article explains the process of exposing legacy APIs, which are hosted on Azure Container Apps, to AI Agents, as Model Context Protocol (MCP) servers by utilizing Azure API Management.
Use Case
Imagine your organization has a legacy REST API hosted on Azure Container Apps that core business systems depend on (order management, pricing, inventory, etc.). You now want AI agents (e.g., GitHub Copilot Agent Mode, Claude, internal copilots) to safely discover and invoke that functionality as “tools,” without rewriting the backend or loosening governance.
To showcase the use case, we deploy an e-commerce application that includes these legacy API endpoints onto Azure Container Apps. For demonstration purposes, we use the Store API a widely used REST API designed for e-commerce prototyping. The exposed endpoints are then published as MCP Server endpoints through Azure API Management, providing agents a standards-based entry point with centralized security, throttling, and observability. Following this, Visual Studio Code is used to consume these endpoints, facilitating modern and efficient API access for client applications.
Deploy Sample Store App to Azure Container Apps
Deploy the Store App to Azure Container Apps. The App offers realistic endpoints for managing products, users, shopping carts, and authentication. Fork the Store API and build the .Dockerfile and provide the below details to create the App. More details on deployment could be found here .
az group create --name "store-app-rg" --location "East US" az containerapp env create --name "store-app-env" --resource-group "store-app-rg" --location "East US" az containerapp create --name "store-app" --resource-group "store-app-rg" --environment "store-app-env" --image "voronalk/fakestoreapi:latest" --target-port 3000 --ingress external --min-replicas 1 --max-replicas 5 --cpu 0.5 --memory 1Gi --env-vars PORT=3000 az containerapp show --name "store-app" --resource-group "store-app-rg" --query "properties.configuration.ingress.fqdn" --output table
Create an Azure API Management Instance
To securely create, expose and govern MCP servers and their backends, API management instance is created. It also provides centralized control over MCP server authentication, authorization, and monitoring.
az group create --name "store-app-rg" --location "East US" az apim create --name "store-app-apim" --resource-group "store-app-rg" --location "East US" --publisher-email "admin@example.com" --publisher-name "Store App Publisher" --sku-name Developer
Import the Storefront Open API Specification in Azure API Management
The APIs which are hosted on Azure Container Apps needs to be imported to Azure API Management such that the existing APIs can be exposed through MCP Server without rewriting their backends. The Open API Specification provides options to quick import and creates Proxies within API Management
# First get the Container App URL
CONTAINER_APP_URL=$(az containerapp show --name "store-app" --resource-group "store-app-rg" --query "properties.configuration.ingress.fqdn" --output tsv)
# Import the API
az apim api import --resource-group "store-app-rg" --service-name "store-app-apim" --api-id "store-api" --path "/storeapp" --specification-format "OpenApi" --specification-url "https://fakestoreapi.com/docs-data" --display-name "Store API" --protocols https --service-url "https://$CONTAINER_APP_URL"
Here is the Open API representation of the Legacy Store Endpoints
Expose the Legacy APIs as a MCP Server
Navigate to APIs, select MCP Servers > + Create MCP server. Provide the endpoints that needs to be available as MCP server. Select the operations required to be exposed to the AI Agents. Follow the steps for more details
Below, the MCP server is created, and the API operations are exposed as tools. The MCP server is listed in the MCP Servers blade. The Server URL column shows the endpoint of the MCP server to call for testing or within a client application.
Configure the MCP Server from VS Code
Follow the steps mentioned here to configure the MCP Server in VS Code. The MCP endpoint created in the above step is protected by an API Key, ensure that the key details are provided in the configuration.
Update the settings.json with the following configuration
Update the mcp.json with the following configuration providing the MCP endpoint for the AI Agents
Query the MCP Server endpoint from VS Code Chat
Following is the response from the query on requesting the MCP endpoint.
Following are some of the other prompts you could try
- Show me all the products available in the Store
- List the top 10 products from Store
- Give me all men’s clothing and sort them by price
- Find all carts created between 2020-10-01 and 2020-12-31