# Creating Azure API Management Service Instance and Importing Backend APIs

### 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.

![APIM_v1.JPG](https://cdn.hashnode.com/res/hashnode/image/upload/v1624241366570/phkIG8nOC.jpeg)
**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](Link) 

Step 1. Once signed-in, search for APIM service as showed below


![1.JPG](https://cdn.hashnode.com/res/hashnode/image/upload/v1624245327406/RAIHKv9Pl.jpeg)


Step 2. In APIM service page, click on the “Create” option
![2.JPG](https://cdn.hashnode.com/res/hashnode/image/upload/v1624241764611/j313WlJj0.jpeg)


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



![3.jpg](https://cdn.hashnode.com/res/hashnode/image/upload/v1624245494643/sVByi7cb6.jpeg)


![4.jpg](https://cdn.hashnode.com/res/hashnode/image/upload/v1624245505622/vZ_AhBaeV.jpeg)

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

![5.jpg](https://cdn.hashnode.com/res/hashnode/image/upload/v1624246119755/3xYql7om1.jpeg)

Step5. Once the creation of APIM service is successful, navigate to the newly created APIM service


![6.jpg](https://cdn.hashnode.com/res/hashnode/image/upload/v1624245583538/m9W5sprvN.jpeg)

### Import and publish backend APIs

Step6. Navigate to the newly created service **labs-demo** and click on **API ** option from the left blade

![7.jpg](https://cdn.hashnode.com/res/hashnode/image/upload/v1624242963747/f588HDjOb.jpeg)


Step7. To import APIs, click on **Add API** and select **OpenAPI** under **Create from definition **


![8.jpg](https://cdn.hashnode.com/res/hashnode/image/upload/v1624245613625/AW_-8-xYO.jpeg)

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](Link)). 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
 


![9.jpg](https://cdn.hashnode.com/res/hashnode/image/upload/v1624243956629/BvLbKPTY7.jpeg)


![10.jpg](https://cdn.hashnode.com/res/hashnode/image/upload/v1624243914031/1rEp9Fsn5.jpeg)


![11.jpg](https://cdn.hashnode.com/res/hashnode/image/upload/v1624243863968/ODBYerZGa.jpeg)


Step9. Once created, the endpoints can be viewed under **API** section in the name **Demo Conference API**

![12.jpg](https://cdn.hashnode.com/res/hashnode/image/upload/v1624244117193/Ee1Avsa6x.jpeg)


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**) 

![13.jpg](https://cdn.hashnode.com/res/hashnode/image/upload/v1624244776487/M94caom2L.jpeg)


> 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

![14.jpg](https://cdn.hashnode.com/res/hashnode/image/upload/v1624244928411/ana7Iwqk3.jpeg)

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: https://labs-apim.azure-api.net/speaker/10

- Base URL: https://labs-apim.azure-api.net

- Path Context to specific endpoint: /speaker/{id}


![15.jpg](https://cdn.hashnode.com/res/hashnode/image/upload/v1624245081114/TcqYIAd6n.jpeg)

### References

-  [https://docs.microsoft.com/en-us/azure/api-management/api-management-key-concepts](Link) 

-  [https://docs.microsoft.com/en-us/azure/api-management/get-started-create-service-instance](Link) 

-  [https://docs.microsoft.com/en-us/azure/api-management/import-and-publish](Link) 






















