How to Integrate Azure CDN with Web Apps: A Step-by-Step Guide


Boost your Azure Web App’s performance by integrating it with Azure CDN! This guide walks you through setting up a CDN profile, creating an endpoint, configuring custom domains & caching, and optimizing performance & security. Follow these steps to accelerate content delivery and enhance user experience. 


1. Prerequisites

  • An Azure account with an active subscription.
  • A deployed Azure Web App.
  • Basic familiarity with Azure Portal.

2. Create an Azure Web App (if not already created)

If you don’t have a Web App yet, follow these steps:

  1. Go to Azure PortalApp ServicesCreate.
  2. Fill in:
    • Subscription: Select your subscription.
    • Resource Group: Create a new or select an existing one.
    • Name: Unique name (e.g., mywebapp123.azurewebsites.net).
    • Publish: Code or Docker Container.
    • Runtime Stack: Choose the appropriate one (e.g., .NET, Java, Node.js).
    • Region: Select a region near your audience.
  3. Click Review + CreateCreate.
  4. Wait for deployment and click Go to resource.

3. Create an Azure CDN Profile

Azure CDN improves the performance and reliability of your web app by caching content in globally distributed locations.

  1. Go to Azure Portal → Search for CDN Profiles.
  2. Click Create.
  3. Fill in:
    • Subscription: Select your subscription.
    • Resource Group: Choose the same as your Web App.
    • CDN Profile Name: Unique name (e.g., mycdnprofile).
    • Pricing Tier: Choose a provider:
      • Microsoft Standard (recommended for general use).
      • Akamai Standard/Premium.
      • Verizon Standard/Premium.
    • Region: Keep it the same as the Web App.
  4. Click Review + CreateCreate.

4. Create an Azure CDN Endpoint

  1. Open your CDN Profile.
  2. Click + Endpoint.
  3. Configure:
    • Name: Unique name (e.g., mycdnendpoint).
    • Origin Type: Choose App Service.
    • Origin Hostname: Select your Web App.
    • Origin Host Header: Leave as default.
  4. Click Add.
  5. Wait for deployment.

5. Configure Custom Domain (Optional)

If you want to use a custom domain (e.g., cdn.mywebsite.com), follow these steps:

  1. In your CDN Endpoint, go to Custom Domains.
  2. Click + Custom domain.
  3. Enter your custom domain (e.g., cdn.mywebsite.com).
  4. Update your DNS records:
    • Add a CNAME record pointing to your CDN Endpoint (mycdnendpoint.azureedge.net).
  5. Click Validate and Save.

6. Enable HTTPS (Optional)

  1. In your CDN Endpoint, go to Custom Domains.
  2. Select your domain → Enable HTTPS.
  3. Choose CDN-Managed or bring your own SSL certificate.
  4. Click Save.

7. Test and Verify CDN

  1. Go to your CDN Endpoint URL (e.g., https://mycdnendpoint.azureedge.net).
  2. Check if content loads correctly.
  3. Use browser developer tools (F12 → Network tab) to verify CDN caching.
  4. Test performance using Azure CDN verification tool.

8. Configure Caching Rules (Optional)

If you need custom caching policies, go to:

  1. Azure CDN ProfileEndpointCaching Rules.
  2. Configure:
    • Bypass caching for dynamic content.
    • Force caching for static assets (CSS, JS, images).
    • Expiration policies.

9. Purge CDN Cache (When Needed)

To refresh content, go to:

  • Azure CDN EndpointPurge → Enter file path or /* to clear all.

10. Automate Deployment (CI/CD)

You can use Azure DevOps or GitHub Actions to automate Web App and CDN deployments.

Popular posts from this blog

Learn Java 8 streams with an example - print odd/even numbers from Array and List

Java Stream API - How to convert List of objects to another List of objects using Java streams?

Registration and Login with Spring Boot + Spring Security + Thymeleaf

Java, Spring Boot Mini Project - Library Management System - Download

ReactJS, Spring Boot JWT Authentication Example

Top 5 Java ORM tools - 2024

Java - Blowfish Encryption and decryption Example

Spring boot video streaming example-HTML5

Google Cloud Storage + Spring Boot - File Upload, Download, and Delete