Prerequisites
- Azure Subscription
Introduction: Azure API Management
In this digital era, businesses everywhere are looking into a way of extending their operations as a digital platform, creating new channels, integrating with multiple platforms and achieve a developer friendly ecosystem.
API Management (APIM) provides a robust method to ensure a successful API program through developer engagement, business insights, analytics, security and protection. Azure API Management service helps developers and organisations a robust means to publish their APIs to external world (partners, customers/end-users) with ease and speed.
The below figure (Figure.1) depicts a pictorial view of a developer who subscribed to APIM product, accessing the product’s associated API (APIs are hosted by internal backend service) via APIM Service using API gateway endpoint.
Figure.1: Azure API Management Service Overview
Create an Azure API Management (APIM) instance using Azure portal
To create an APIM service, login to https://portal.azure.com
Step 1. Once signed-in, search for APIM service as showed below
Step 2. In APIM service page, click on the “Create” option
Step3. In create section, enter all the required fields to create a new APIM service
Resource Group: Select existing or a create new resource group
Region: Azure region in which the APIM service will be spawned
Resource Name: API Management instance name
Organization Name: To use in developer portal and sending email notifications
Administrator email: To receive all system notifications from APIM
In this article, the pricing tier is selected as “Developer”. The Developer tier of API Management does not include SLA and should not be used for production purposes. Your service may experience intermittent outages, for example during upgrades.
Note: Apart from Basics section, all other sections (Monitoring, Scale, Managed Identity, Virtual Network, Protocol Settings, Tags) are left to default values in this article
Step4. Click on Review + Create and once the validation passed, click on Create button to proceed for APIM service creation
Step5. Once the creation of APIM service is successful, navigate to the newly created APIM service
Import and publish backend APIs
Step6. Navigate to the newly created service labs-demo and click on API option from the left blade
Step7. To import APIs, click on Add API and select OpenAPI under Create from definition
Step8. In OpenAPI specification, enter details as follows
OpenAPI Specification: In this article, Microsoft provided backend APIs sample is used (https://conferenceapi.azurewebsites.net?format=json). The API specification can be added as an endpoint URL or uploaded as a file
Enter Display name, Name, description
URL scheme: Select HTTP or HTTPS or Both. For production, HTTPS is recommended
API URL Prefix: A suffix appended to the base URL of the API Management service. The suffix must be unique for every API for a given publisher
Tags: Organising APIs for grouping, searching and filtering
Products: To associate APIs to a product. By default, APIM instance comes with two products. Here, a default product Starter is used to associate the APIs to publish
Gateway: To expose the API. This field is available only in Developer and Premium tier services
Version: To version the APIs
Step9. Once created, the endpoints can be viewed under API section in the name Demo Conference API
Step10. Now, test the APIs from APIM by navigating to Test tab,
Step 10.1. Select the API to test (Here, GetSpeaker endpoint is taken for testing)
Step 10.2. Input the required input parameters (Speaker ID)
Step 10.3. Click Send and observe the response from the backend API (200 OK)
Note: To publish the API to API consumers, this must be associate with a product and while sending the request to API, subscription key (Ocp-Apim-Subscription-Key) needs to be passed in the header. The need to send Ocp-Apim-Subscription-Key as a header for each request can be enabled/disabled at the Settings tab
Accessing the backend APIs using API gateway endpoint using POSTMAN tool.
Note: The API gateway URL can be obtained from the overview section of APIM service instance
Endpoint: labs-apim.azure-api.net/speaker/10
Base URL: labs-apim.azure-api.net
Path Context to specific endpoint: /speaker/{id}