Create Your First API in Azure API Management

Overview

Azure API Management (APIM) allows you to create, manage, secure, and document your APIs. This guide walks you through importing your first API and exposing it through the APIM gateway. By the end of this tutorial, you'll have a working API endpoint that external developers can consume.

What You'll Learn

  • How to create an Azure API Management instance
  • Different ways to import an API (OpenAPI, blank API)
  • Adding operations to your API
  • Testing your API through the Azure portal
  • Understanding the URL structure

Prerequisites

  • Azure subscription
  • An existing API (or use mock)

Step 1: Create APIM Instance

Via Portal

  1. Search "API Management services"
  2. Click Create
  3. Configure:
    • Name: my-apim
    • Subscription: Your subscription
    • Resource Group: Create or select
    • Location: Choose region
    • Pricing tier: Consumption (or Basic)
    • Organization name: Your company
    • Administrator email: Your email
  4. Click Create

Wait ~30-40 minutes for deployment.


Step 2: Import an API

Option 1: OpenAPI (REST)

  1. Go to APIM → APIs
  2. Click + Add API
  3. Select OpenAPI specification
  4. Configure:
    • Display name: "My API"
    • Name: my-api
    • Web service URL: https://api.example.com
    • API URL suffix: v1
  5. Click Create

Option 2: Blank API (Manual)

  1. Click + Add API
  2. Select Blank API
  3. Configure:
    • Display name: "Manual API"
    • Name: manual-api
    • API URL suffix: manual
  4. Click Create

Step 3: Add Operation

If using Blank API

  1. Select your API
  2. Click + Add operation
  3. Configure:
    • Display name: "Get Products"
    • Name: GetProducts
    • URL: GET /products
    • Description: Get all products
  4. Click Save

Step 4: Test the API

In Azure Portal

  1. Select API → Operation
  2. Click Test tab
  3. Click Send

Via URL

https://my-apim.azure-api.net/v1/products

API URL Structure

https://{apim-name}.azure-api.net/{suffix}/{path}

Example:
https://my-apim.azure-api.net/v1/products

Backend URL

The backend URL is where APIM forwards requests to.

Configure Backend

  1. Select API
  2. Click Settings
  3. Modify Web service URL

Real-Time Scenarios

Scenario 1: Calling Local Development API (localhost)

During development, you might want APIM to call your local machine. Use the APIM ManagementProxyTest feature or set up a mock backend.

# For local development, configure:
Web service URL: http://localhost:5000

# Or use ngrok for external access:
Web service URL: https://your-ngrok-url.ngrok.io

Scenario 2: Data Processing Pipeline

APIM can orchestrate data processing workflows:

Client → APIM → Azure Function (validate) 
         → APIM → Azure Function (transform) 
         → APIM → Blob Storage (store result)

Scenario 3: Multiple Backend Services

Aggregate multiple APIs into one unified endpoint:

# Single APIM endpoint calling multiple backends
GET /api/orders          → Backend: Order Service (http://orders.internal/api)
GET /api/inventory       → Backend: Inventory Service (http://inventory.internal/api)
GET /api/shipping        → Backend: Shipping Service (http://shipping.internal/api)

Scenario 4: Mock API for Testing

Create a mock response without a real backend:

  1. Select your API → Settings
  2. Set Web service URL to a non-existent URL (or leave empty)
  3. Add Mock responses to operations:
    • Select Operation → Add policy → mock-response
    • Return sample JSON responses

Common Issues & Solutions

IssueSolution
502 Bad GatewayCheck backend URL is accessible
401 UnauthorizedVerify subscription key or auth policy
404 Not FoundCheck API URL suffix and operation path
TimeoutIncrease backend timeout in API settings

Next Steps


Azure Integration Hub - Beginner Level