Protect APIs with Azure Application Gateway and Azure API Management - Azure Architecture Center (2024)

With more workloads adhering to the API-first approach for their design, and the growing number and severity of threats to web applications over the internet, it's critical to have a security strategy to protect APIs. One step toward API security is protecting the network traffic by using the Gateway Routing pattern. You use the gateway to restrict traffic source locations and traffic quality in addition to supporting flexible routing rules. This article describes how to use Azure Application Gateway and Azure API Management to protect API access.

Architecture

This article doesn't address the application's underlying services, like App Service Environment, Azure SQL Managed Instance, and Azure Kubernetes Services. Those parts of the diagram only showcase what you can do as a broader solution. This article specifically discusses the shaded areas, API Management and Application Gateway.

Protect APIs with Azure Application Gateway and Azure API Management - Azure Architecture Center (1)

Download a Visio file of this architecture.

Workflow

  • The Application Gateway receives HTTP requests that have been allowed by its subnet's Network Security Group (NSG).

  • The Web Application Firewall (WAF) on Application Gateway then checks the request against WAF rules, including Geomatch filtering. If the request is valid, the request proceeds.

  • Application Gateway sets up a URL proxy mechanism that sends the request to the proper backend pool. For example, depending on the URL format of the API call:

  • Also, Application Gateway accepts and proxies internal calls, which come from resources in the same Azure virtual network, under api.<some-domain>/internal/*.

  • Finally, at the API Management level, APIs are set up to accept calls under the following patterns:

    • api.<some-domain>/external/*
    • api.<some-domain>/internal/*

    In this scenario, API Management uses two types of IP addresses, public and private. Public IP addresses are for internal communication on port 3443, and for runtime API traffic in the external virtual network configuration. When API Management sends a request to a public internet-facing back end, it shows a public IP address as the origin of the request. For more information, see IP addresses of API Management service in VNet.

  • A routing rule at the Application Gateway level properly redirects users under portal.<some-domain>/* to the developer portal, so that developers can manage APIs and their configurations from both internal and external environments.

Components

  • Azure Virtual Network enables many types of Azure resources to privately communicate with each other, the internet, and on-premises networks.

  • Azure Application Gateway is a web traffic load balancer that manages traffic to web applications. This type of routing is known as application layer (OSI layer 7) load balancing. It hosts a Web Application Firewall (WAF) to protect against common web-based attack vectors.

  • Azure API Management is a hybrid, multicloud management platform for APIs across all environments. API Management creates consistent, modern API gateways for existing backend services.

Recommendations

This solution focuses on implementing the whole solution, and testing API access from inside and outside the API Management virtual network. For more information about the API Management virtual network integration process, see Integrate API Management in an internal VNET with Application Gateway.

To communicate with private resources in the back end, Application Gateway and API Management must be in the same virtual network as the resources or in a peered virtual network.

  • The private, internal deployment model allows API Management to connect to an existing virtual network, making it reachable from the inside of that network context. To enable this feature, deploy either the Developer or Premium API Management tiers.

  • Manage certificates and passwords in Azure Key Vault.

  • To personalize interactions with the services, you can use CNAME entries.

Alternatives

You can use other services to deliver a similar level of firewall and Web Application Firewall (WAF) protection:

  • Azure Front Door
  • Azure Firewall
  • Partner solutions like Barracuda
  • Other solutions available in Azure Marketplace

Considerations

Reliability

Azure Application Gateway is always deployed in a highly available fashion, no matter the instance count. To avoid the impact of a zone malfunction, you can configure the Application Gateway to span multiple Availability Zones. For more information, see Autoscaling and High Availability.

Enable zone redundancy for your API Management service components to provide resiliency and high availability. Zone redundancy replicates the API Management gateway and control plane across datacenters in physically separated zones, making them resilient to zone failure. The API Management Premium tier is required to support Availability zones.

API Management also supports multi-region deployments, which can improve availability if one region goes offline. For more information, see Multi-region deployment. In this topology, it's important to also have one Application Gateway per region, since Application Gateway is a regional service.

Security

For more information about Application Gateway security, see Azure security baseline for Application Gateway.

For more information about API Management security, see Azure security baseline for API Management.

Azure DDoS Protection, combined with application-design best practices, provides enhanced DDoS mitigation features to provide more defense against DDoS attacks. You should enable Azure DDOS Protection on any perimeter virtual network.

Cost optimization

The cost of this architecture depends on configuration aspects like:

  • Service tiers
  • Scalability, meaning the number of instances dynamically allocated by services to support a given demand
  • Whether this architecture will run continuously or just a few hours a month

After you assess these aspects, go to the Azure Pricing Calculator to estimate pricing.

Performance efficiency

Application Gateway is the entry point for this architecture, and the WAF feature requires additional processing power for each request analysis. To allow Application Gateway to expand its computational capacity on the spot, it's important to enable autoscaling. For more information, see Specify autoscale. Follow product documentation recommendations the size of the subnet for Application Gateway. This ensures subnet is large enough to support full scale-out.

To support highly concurrent scenarios, turn on API Management autoscaling. Autoscaling expands API Management capabilities in response to growing numbers of incoming requests. For more information, see Automatically scale an Azure API Management instance.

Deploy this scenario

This scenario is demonstrated in the Azure Quickstart gallery publication of Application Gateway with internal API Management and Web App.

Next steps

Design your APIs following good Web API design guidelines and implement them using good Web API implementation practices.

  • URL path-based routing overview
  • Tutorial: Create an application gateway with path-based routing rules using the Azure portal
  • Tutorial: Create an application gateway with URL path-based redirection using the Azure CLI
Protect APIs with Azure Application Gateway and Azure API Management - Azure Architecture Center (2024)

FAQs

What is the difference between API Management and API gateway in Azure? ›

The Differences Between API Management and API Gateways

API Gateways are components of an overall API management solution. While one provides a management solution foFr APIs, the other is a proxy service in front of your existing infrastructure.

How to secure an Azure API gateway? ›

Azure AD Authentication Required for Data Plane Access
  1. Configure your Azure API Management Developer Portal to authenticate developer accounts by using Azure AD.
  2. Configure your Azure API Management instance to protect your APIs by using the OAuth 2.0 protocol with Azure AD.
Feb 7, 2024

What is the main purpose of creating an API gateway within Azure API Management? ›

An API gateway sits between clients and services. It acts as a reverse proxy, routing requests from clients to services. It may also perform various cross-cutting tasks such as authentication, SSL termination, and rate limiting. If you don't deploy a gateway, clients must send requests directly to front-end services.

How to secure API endpoints in Azure? ›

Get a token issuer endpoint

Next, get the well-known config URL for one of your Azure AD B2C user flows. You also need the token issuer endpoint URI that you want to support in Azure API Management. In the Azure portal, go to your Azure AD B2C tenant. Under Policies, select User flows.

What is the purpose of an API Gateway in an API architecture? ›

An API gateway is a data-plane entry point for API calls that represent client requests to target applications and services. It typically performs request processing based on defined policies, including authentication, authorization, access control, SSL/TLS offloading, routing, and load balancing.

What is the difference between an API and an API Gateway? ›

API Design: Creating well-defined endpoints and specifying the API's function, including request and response structures. API Gateway: Serving as the entry point for API requests, responsible for tasks like routing, load balancing, and request and response transformation.

How do I make my API gateway secure? ›

You can protect your API using strategies like generating SSL certificates, configuring a web application firewall, setting throttling targets, and only allowing access to your API from a Virtual Private Cloud (VPC).

What are the security concerns of API gateway? ›

Common API security risks
  • Broken object-level aAuthorization (BOLA) ...
  • Broken user authentication. ...
  • Improper asset management. ...
  • Excessive data exposure. ...
  • Lack of resources & rate limiting. ...
  • Broken function level authorization. ...
  • Injection attacks. ...
  • DDoS attacks.
Feb 6, 2024

What is the main security policy in API gateway? ›

A security policy is a predefined combination of minimum TLS version and cipher suites offered by API Gateway. You can choose either a TLS version 1.2 or TLS version 1.0 security policy. The TLS protocol addresses network security problems such as tampering and eavesdropping between a client and server.

Why should I use Azure API Management? ›

Azure API Management helps customers meet these challenges: Abstract backend architecture diversity and complexity from API consumers. Securely expose services hosted on and outside of Azure as APIs. Protect, accelerate, and observe APIs.

What is the benefit of Application Gateway in Azure? ›

Azure Application Gateway helps in SSL termination at the gateway level itself, allowing communication between backend instances. This feature removes the encryption and decryption overhead from the backend server, and that makes the entire process a little faster and also decreases the response time.

When should API gateway be used? ›

Use API Gateway to create HTTP APIs

For example, you can create an HTTP API that integrates with a Lambda function on the backend. When a client calls your API, API Gateway sends the request to the Lambda function and returns the function's response to the client.

How do I protect my Azure API Management? ›

In this module, you will:
  1. Create an Azure API gateway.
  2. Import a RESTful API into the gateway.
  3. Implement policies to limit unintended information exposure and throttle the requests.
  4. Call an API to test the applied policies.

How do I protect my API endpoints? ›

API Security Best Practices
  1. Always Use a Gateway.
  2. Always Use a Central OAuth Server.
  3. Only Use JSON Web Tokens Internally.
  4. Use Scopes for Coarse-Grained Access Control.
  5. Use Claims for Fine-Grained Access Control at the API Level.
  6. Trust No One.
  7. Create or Reuse Libraries for JWT Validation.
  8. Do Not Mix Authentication Methods.

What is API Management in Azure? ›

Azure API Management is a hybrid, multicloud management platform for APIs across all environments. As a platform-as-a-service, API Management supports the complete API lifecycle. Tip. If you're already familiar with API Management and ready to start, see these resources: Features and service tiers.

What is the difference between Azure API Management and Azure App service? ›

Have you used any of these products before? Microsoft's Azure API Management supports creation of API. The Microsoft Azure App Service is a PaaS that enables users to build, deploy, and scale web apps and APIs, a fully managed service with built-in infrastructure maintenance, security patching, and scaling.

What is the difference between API Gateway and API endpoints? ›

The main difference is that API Gateway can route a request to multiple backends, but Cloud Endpoints can route traffic only to a single backend. API Gateway can do anything that Cloud Endpoints can do but vice versa is not always true.

What is the difference between API portal and API Gateway? ›

In essence, an API Gateway acts as a traffic manager. Unlike catalogs or portals that serve as directories or interfaces, gateways directly affect APIs' functions. They consolidate multiple backend services into a unified API, manage requests, and enhance overall performance and security.

Top Articles
Latest Posts
Article information

Author: Pres. Carey Rath

Last Updated:

Views: 5825

Rating: 4 / 5 (41 voted)

Reviews: 80% of readers found this page helpful

Author information

Name: Pres. Carey Rath

Birthday: 1997-03-06

Address: 14955 Ledner Trail, East Rodrickfort, NE 85127-8369

Phone: +18682428114917

Job: National Technology Representative

Hobby: Sand art, Drama, Web surfing, Cycling, Brazilian jiu-jitsu, Leather crafting, Creative writing

Introduction: My name is Pres. Carey Rath, I am a faithful, funny, vast, joyous, lively, brave, glamorous person who loves writing and wants to share my knowledge and understanding with you.