Create An API Gateway

 


Intro

An Azure API gateway is an instance of the Azure API management service.


Documentation



 


Tips and Tidbits

  • The name you use for the gateway must be globally unique within the .azure-api.net namespace.

 

 


Steps

 

 

Deploy a Web App

 

git clone https://github.com/MicrosoftDocs/mslearn-publish-manage-apis-with-azure-api-management.git

 

*********************** IMPORTANT INFO ********************* Swagger URL: https://ShoeCoAPI970b9d9a89.azurewebsites.net/swagger Swagger JSON URL: https://ShoeCoAPI970b9d9a89.azurewebsites.net/swagger/v1/swagger.json

 

 

Deploy an API gateway



 


Import and publish an API

  • Import and publish an API

  • To make an API available through an API gateway, you need to import and publish the API.

  • Making an API available starts with importing the API into API Management. You can then:

    • Use the visualization tools in the API gateway to test out your API.

    • Manage access to your APIs using policies.

There are various API frameworks and standards. API Management provides you with several options for importing APIs.

Type

Details

Type

Details

Blank API

You can import an API with a blank API definition. You then manually specify all the required parameters.

Open API

Open API is a specification that documents all the endpoints and operations for RESTful APIs, and all input and output parameters. OpenAPI was originally called Swagger.

WADL

Web Application Description Language is an XML description of HTTP-based web services. It is a simpler format and more lightweight than WSDL.

WSDL

Web Service Description Language is an XML description of any network service, not just HTTP.

Logic App

Logic apps are used to orchestrate and automate workflows and integrations with various data sources.

API App

An API hosted within an API app service in Azure.

Function App

Serverless code that can be called through triggers.

Exercise - Import and publish an API

 

OpenAPI specification

Paste the swagger JSON URL that you saved from the previous exercise.




https://shoecoapi970b9d9a89.azurewebsites.net/swagger/v1/swagger.json { "swagger": "2.0", "info": { "version": "v1", "title": "NorthWindShoes Products" }, "host": "shoecoapi970b9d9a89.azurewebsites.net", "paths": { "/api/Inventory": { "get": { "tags": [ "Inventory" ], "summary": "Retrieve the entire product inventory for the company.", "operationId": "GetInventory", "consumes": [], "produces": [ "text/plain", "application/json", "text/json" ], "parameters": [], "responses": { "200": { "description": "Success", "schema": { "uniqueItems": false, "type": "array", "items": { "$ref": "#/definitions/Inventory" } } } } } }, "/api/Inventory/{productid}": { "get": { "tags": [ "Inventory" ], "summary": "Retrieve the number in stock for the specified product", "operationId": "GetInventoryItem", "consumes": [], "produces": [ "text/plain", "application/json", "text/json" ], "parameters": [ { "name": "productid", "in": "path", "required": true, "type": "integer", "format": "int32" } ], "responses": { "200": { "description": "Success", "schema": { "$ref": "#/definitions/Inventory" } } } } }, "/api/Products": { "get": { "tags": [ "Products" ], "summary": "Retrieve the details of every product sold", "operationId": "GetProducts", "consumes": [], "produces": [ "text/plain", "application/json", "text/json" ], "parameters": [], "responses": { "200": { "description": "Success", "schema": { "uniqueItems": false, "type": "array", "items": { "$ref": "#/definitions/Product" } } } } } }, "/api/Products/{productid}": { "get": { "tags": [ "Products" ], "summary": "Find the details of the specified product", "operationId": "GetProductDetails", "consumes": [], "produces": [ "text/plain", "application/json", "text/json" ], "parameters": [ { "name": "productid", "in": "path", "required": true, "type": "integer", "format": "int32" } ], "responses": { "200": { "description": "Success", "schema": { "$ref": "#/definitions/Product" } } } } } }, "definitions": { "Inventory": { "type": "object", "properties": { "productID": { "format": "int32", "type": "integer" }, "numberInStock": { "format": "int32", "type": "integer" } } }, "Product": { "type": "object", "properties": { "productID": { "format": "int32", "type": "integer" }, "productName": { "type": "string" }, "productLaunchDate": { "format": "date-time", "type": "string" }, "productLaunchPrice": { "format": "int32", "type": "integer" } } } } }

 

Visualize the API

 

 

 

 


Subscription Keys

 

  • When you publish an API, you often want some level of control over who can access the API through the gateway. Subscription keys are used to restrict access to an API.

  •  

  • A subscription key is a unique auto-generated string which needs to be passed through in the headers of the client request.

  • The key is directly related to a subscription which can be scoped to different areas, this gives granular control over permissions and policies.

  • The three main subscription scopes are:

    • All APIs

    • A Single API

    • A product

 

 

With the key in the header

 


Deploy the Weather Web API

 

 

  •  all dependencies needed for our app to run are automatically installed on the remote App Service.

 

 

 

 

Â