How Azure Application Gateway Protects and Optimizes Your Web Applications
Home » Ashfarq Kariapper  »  How Azure Application Gateway Protects and Optimizes Your Web Applications
How Azure Application Gateway Protects and Optimizes Your Web Applications

How Azure Application Gateway with WAF Saved My Client’s Digital Platform

As a Cloud Architect, I’ve worked with organizations of all sizes—but one experience I often share was with a humble, family-run bakery in Sri Lanka that made a bold move: taking their entire business online.

Their brand, let me name it as "Golden Loaf" 😉, had always been a local favorite. this was initially built in on-prem server with high complexity of even finding the their application. But when they launched their new e-commerce website built on Azure App Service, orders started pouring in from all corners of the island—and soon, from abroad. However, with growth came risk.

Within weeks of going live, their internal IT team started flagging issues:

  • Customers reported strange pop-ups on the site
  • Login attempts spiked at odd hours
  • The backend logs showed suspicious SQL-like inputs in form fields

It didn’t take long to confirm: they were under active attack.

The application was open to SQL injection, cross-site scripting (XSS), and bot traffic probing for vulnerabilities. While their developers had done a great job, they hadn’t yet implemented enterprise-grade edge protection.

My Solution: Azure Application Gateway + WAF v2 + Azure DDoS

To secure the platform without redesigning it, I proposed a solution built on Azure Application Gateway with Web Application Firewall (WAF v2).

What changed?

  • Attack traffic dropped by 90% — most of it was blocked at the edge
  • The team could see attacks in real-time using Log Analytics
  • Customers no longer faced any security-related issues
  • The platform performance improved due to smart routing and offloading SSL at the gateway

The owners of Golden Loaf were amazed—not only was their website fast and reliable, it was secure and resilient.

So what is Microsoft Azure Application Gateway + Web APplication Firewall?

Microsoft Azure Application Gateway is a powerful, application-level web traffic load balancer that not only distributes incoming traffic across your services, but also enhances your security posture and performance through advanced, layered features. Here’s an in-depth look at how it safeguards and optimizes modern web applications.

Main Features of Application Gateway for protection of the application are following:

  • Protecting your Web Applications
  • OptimizationEnhancing Performance & Availability
figure1-720

Protecting your Web Applications

These are the following ways to protect and secure your Web Applications:

1. Web Application Firewall (WAF)

  • Integrated Security: Azure Application Gateway features a built-in Web Application Firewall (WAF), designed to protect web applications from common threats such as SQL injection, cross-site scripting (XSS), and other vulnerabilities outlined in the OWASP Top 10. Attacks That Azure WAF on Application Gateway Can Overcome
  • SQL Injection (SQLi)
    Prevents unauthorized access or manipulation of your database via malicious input in forms, URLs, or headers.
    Eg: Any SQL codes with followinf will be bloked:
    ' OR 1=1 --
  • Cross-site Scripting (XSS)
    Blocks attempts to inject malicious scripts into web pages viewed by other users.
    Eg: scripts that are designed with the following html codes will be blocked
    <script>alert('Hacked')</script>
  • Remote Code Execution (RCE)
    This prevents attackers from injecting and executing malicious code on servers.
    Eg: Trying to run commands like exec('cmd.exe') via input fields. 
  • Local File Inclusion (LFI) & Remote File Inclusion (RFI)
    Blocks attempts to include sensitive local files (/etc/passwd) or remote malicious scripts into the web server response.
  • Command Injection
    Prevents attackers from injecting system commands (e.g., using semicolons or pipes) into user inputs that are later executed on the backend server.
  • Cross-site Request Forgery (CSRF)
    Detects patterns used in CSRF attacks, though protection should also be implemented in application code.
  • Session Fixation and Hijacking
    Detects suspicious cookies or session anomalies to prevent theft of session tokens.
  • Broken Access Control Attempts
    Blocks access to sensitive URL patterns or headers that should not be accessible to certain users.
  • Java Injection / XML Injection 
    Detects attempts to inject malicious Java/XML payloads to manipulate backend logic or services.
  • Bots and Crawlers
    Detects abnormal user-agent headers or request patterns common in bot attacks, scrapers, or DDoS.
    this is achieved partially through custom rul
  • Buffer Overflow / Payload Attacks
    Inspects unusually large payloads or malformed headers designed to crash or exploit applications.

So the above depends either we are choosing a detection feaure or the preventive feature

  • Custom Policy & Rules: WAF policies can be tailored for each site, listener, or routing rule, providing site-specific protection and the ability to customize or exclude particular rules to minimize false positives.

  • Real-Time Monitoring: Logs attacks and alerts through Azure Monitor, providing transparency, auditability, and integration with Microsoft Defender for Cloud for a unified security dashboard

  • Bot and DDoS Defense: Includes intelligent defenses against malicious bots and distributed denial-of-service (DDoS) attacks, with IP reputation rule sets and Azure DDoS Protection integration. this is an additional resource (Azure DDoS Protection) that needs to be deployed to ensure more security

DDoS-Attack-and-Web-Application-Firewall-web-mobile-cloud

  • Rate Limiting & Throttling: Controls to prevent abuse from traffic spikes or malicious automated sources, further securing backend resources
02fig01
2. End-to-End SSL/TLS Encryption

  • SSL Termination & Offload: Decrypts incoming SSL/TLS traffic at the gateway, offloading resource-intensive encryption from backend servers
http-vs-https

  • End-to-End Security: Optional full encryption—re-encrypting traffic between the gateway and your backend—meets compliance and privacy requirements
tls-1.3-handshake-performance
3. Advanced Layer 7 Security Features

  • Session Affinity: Uses cookies to pin a user session to a specific backend, helping mitigate session hijacking risks

  • Geo-Filtering & Custom Rules: Blocks or allows access by geographic region and applies custom inspection logic, adding additional gates against unauthorized access

Optimization: Enhancing Performance & Availability

These are the following ways to optimiize the performance and availability of the network or the application:

1. Intelligent Load Balancing

  • Layer 7 Awareness: Makes routing decisions based on HTTP request attributes—like URI path, headers, and host—ideal for microservices and modular apps

  • Custom Routing Rules:
  •              -> Multi-site Hosting: Host and manage multiple domains or sites under a single Application Gateway instance, with discrete routing and policies for each
  •              ->  URL Path-Based Routing: Direct specific URLs to different backend services or microservices

  • Health Probes: Constantly monitors backend server health and reroutes traffic away from unhealthy instances, maintaining uptime and reliability
how-application-gateway-works
2. Scalability and High Availability

  • Autoscaling: Dynamically scales up or down based on real-time traffic needs—no manual reconfiguration required. Handles sudden spikes and reduces costs during low-traffic periods

  • Zone Redundancy: Supports deployment across multiple availability zones for robust fault tolerance and disaster recovery
auto-scale-1
3. Performance Optimization

  • SSL/TLS Offloading: Frees backend compute resources, allowing applications to serve more requests with lower latency

  • Header and URL Rewriting: Modifies HTTP/HTTPS requests and responses on the fly, enabling complex routing, redirects, and improved traffic management

  • HTTP/2 & WebSocket Support: Facilitates faster page loads and more efficient communication for modern, real-time web apps

4. Deep Monitoring & Diagnostics

  • Integration with Azure Monitor & Log Analytics: Gain visibility into throughput, health metrics, attack trends, and backend performance, empowering data-driven tuning

  • Proactive Problem Detection: Real-time alerts support rapid troubleshooting and threat mitigation
compute-unit-alert-exp

These are scenarios what I have worked on:

These are the following ways to optimiize the performance and availability of the network or the application:

Project Experience 1:
I have secured numerous backend APIs by integrating Azure Web Application Firewall (WAF) policies with Application Gateway. This setup enabled deep packet inspection, protection against OWASP Top 10 vulnerabilities, and access control based on request headers, IP restrictions, and geolocation. I’ve also implemented routing strategies based on API versioning and business context to manage changes and ensure backward compatibility.

Project Experience 2:
In projects involving microservices-based application deployments, I utilized Application Gateway's path-based and host-based routing capabilities to direct users to the appropriate microservice. This ensured clean separation of services, ease of maintenance, and better performance. I also leveraged custom headers for intelligent routing, which played a key role in handling user authentication and session persistence across services.

Project Experience 3: 
I have been involved in seamlessly transitioning legacy on-premise systems to modern cloud-based infrastructures using Azure Application Gateway. This included designing secure routing mechanisms, implementing SSL termination, and ensuring high availability without compromising on performance. These migrations not only preserved critical business logic but also enabled enhanced scalability and integration with modern services.

Project Experience 4:
For globally distributed applications, I configured Azure Application Gateway with custom probes and multi-region backend pools. This allowed traffic to be routed intelligently to the nearest healthy endpoint based on user location, significantly reducing latency and ensuring business continuity. I’ve worked on solutions that maintained performance SLAs and supported geo-redundancy and failover strategies across continents.

Conclusion

I believe that rather than expecting to receive secure traffic its always better to prepare your environment in a safe and secured manner

Azure Application Gateway is much more than a traditional load balancer. It is a comprehensive tool for protecting and optimizing your web applications—combining cutting-edge security like WAF, DDoS defense, and SSL offloading with intelligent traffic management, advanced routing, autoscaling, and deep diagnostics. By adopting Application Gateway, organizations can achieve scalable, resilient, and secure cloud architectures fit for today’s demanding web workloads

Share the Post on:
WhatsApp Image 2025-03-17 at 13.01.27_45cefa7f

I, M Ashfarq Kariapper, currently working as a Cloud Solution Architect / Tech Lead - Infrastructure. My expertise lies in designing and implementing on-prem and cloud solutions, particularly on Microsoft Azure and traditional environment. Possess extensive experience in cloud infrastructure, Data Engineering, and integrating various enterprise systems like SAP and Oracle. Moreover,  I'm passionate about education and community development initiatives supporting local socio-economic projects in Sri Lanka. Also the Co-Founder of International Council for Virtual & Research Education (Pvt) Ltd.