Bird
Raised Fist0
Azurecloud~5 mins

Azure CDN profiles and endpoints - Commands & Configuration

Choose your learning style10 modes available

Start learning this pattern below

Jump into concepts and practice - no test required

or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Introduction
When you want to deliver your website or app content faster to users worldwide, Azure CDN helps by storing copies of your content closer to them. Azure CDN profiles organize your CDN settings, and endpoints are the specific addresses where your content is delivered from.
When you want to speed up loading times for your website visitors around the world.
When you want to reduce the load on your main web server by caching content.
When you want to secure your content delivery with HTTPS and custom domains.
When you want to deliver large files like videos or software downloads efficiently.
When you want to improve user experience by reducing delays caused by distance.
Config File - azure-cdn-profile-endpoint.bicep
azure-cdn-profile-endpoint.bicep
param cdnProfileName string = 'exampleCdnProfile'
param cdnEndpointName string = 'exampleCdnEndpoint'
param resourceGroupName string = 'exampleResourceGroup'
param location string = 'eastus'
param originHostName string = 'www.example.com'

resource cdnProfile 'Microsoft.Cdn/profiles@2021-06-01' = {
  name: cdnProfileName
  location: location
  sku: {
    name: 'Standard_Microsoft'
  }
}

resource cdnEndpoint 'Microsoft.Cdn/profiles/endpoints@2021-06-01' = {
  name: '${cdnProfile.name}/${cdnEndpointName}'
  location: location
  properties: {
    origins: [
      {
        name: 'origin1'
        properties: {
          hostName: originHostName
        }
      }
    ]
    isHttpAllowed: true
    isHttpsAllowed: true
  }
  dependsOn: [cdnProfile]
}

This Bicep file creates an Azure CDN profile and an endpoint inside it.

cdnProfile: This is the container for your CDN settings. It uses the Standard Microsoft SKU.

cdnEndpoint: This is where your content is delivered. It points to your origin server (like your website) and allows both HTTP and HTTPS traffic.

The dependsOn ensures the profile is created before the endpoint.

Commands
Create a resource group to hold your Azure CDN profile and endpoint. This groups related resources together.
Terminal
az group create --name exampleResourceGroup --location eastus
Expected OutputExpected
{ "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/exampleResourceGroup", "location": "eastus", "managedBy": null, "name": "exampleResourceGroup", "properties": { "provisioningState": "Succeeded" }, "tags": {}, "type": "Microsoft.Resources/resourceGroups" }
→
--name - Sets the name of the resource group.
→
--location - Sets the Azure region for the resource group.
Deploy the Bicep template to create the CDN profile and endpoint inside the resource group.
Terminal
az deployment group create --resource-group exampleResourceGroup --template-file azure-cdn-profile-endpoint.bicep
Expected OutputExpected
{ "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/exampleResourceGroup/providers/Microsoft.Resources/deployments/deploymentName", "name": "deploymentName", "properties": { "provisioningState": "Succeeded", "outputs": {} } }
→
--resource-group - Specifies the resource group to deploy to.
→
--template-file - Specifies the Bicep template file to deploy.
Check the details of the CDN endpoint to confirm it was created and see its settings.
Terminal
az cdn endpoint show --resource-group exampleResourceGroup --profile-name exampleCdnProfile --name exampleCdnEndpoint
Expected OutputExpected
{ "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/exampleResourceGroup/providers/Microsoft.Cdn/profiles/exampleCdnProfile/endpoints/exampleCdnEndpoint", "name": "exampleCdnEndpoint", "properties": { "hostName": "exampleCdnEndpoint.azureedge.net", "originHostHeader": "www.example.com", "origins": [ { "name": "origin1", "properties": { "hostName": "www.example.com" } } ], "isHttpAllowed": true, "isHttpsAllowed": true }, "type": "Microsoft.Cdn/profiles/endpoints" }
→
--resource-group - Specifies the resource group of the CDN endpoint.
→
--profile-name - Specifies the CDN profile name.
→
--name - Specifies the CDN endpoint name.
Key Concept

If you remember nothing else from this pattern, remember: Azure CDN profiles organize your CDN settings, and endpoints are the specific addresses that deliver your cached content to users.

Common Mistakes
Trying to create a CDN endpoint before creating the CDN profile.
The endpoint depends on the profile, so it cannot be created first.
Always create the CDN profile first, then create endpoints inside it.
Not specifying the correct origin hostname in the endpoint configuration.
The CDN won't know where to get the original content, so caching and delivery will fail.
Set the origin hostname to your actual web server or storage endpoint.
Forgetting to allow HTTPS on the CDN endpoint.
Users may get security warnings or be unable to access content securely.
Enable HTTPS by setting isHttpsAllowed to true in the endpoint properties.
Summary
Create a resource group to hold your Azure CDN resources.
Deploy a Bicep template that creates a CDN profile and an endpoint with your origin server.
Verify the CDN endpoint details to ensure it is set up correctly and ready to deliver content.

Practice

(1/5)
1. What is the primary purpose of an Azure CDN profile?
easy
A. To manage user authentication
B. To store website content directly
C. To group CDN endpoints and define pricing tiers
D. To create virtual machines

Solution

  1. Step 1: Understand the role of a CDN profile

    An Azure CDN profile acts as a container for one or more CDN endpoints and defines the pricing and features for those endpoints.
  2. Step 2: Differentiate from other Azure services

    Profiles do not store content or manage authentication; those are handled by other Azure services.
  3. Final Answer:

    To group CDN endpoints and define pricing tiers -> Option C
  4. Quick Check:

    CDN profile = group endpoints + pricing [OK]
Hint: Profiles group endpoints and set pricing tiers [OK]
Common Mistakes:
  • Confusing profiles with storage accounts
  • Thinking profiles manage user access
  • Assuming profiles store content
2. Which of the following is the correct way to create a new Azure CDN endpoint under an existing profile using Azure CLI?
easy
A. az cdn profile create --name myEndpoint --resource-group myResourceGroup --origin myOrigin
B. az cdn endpoint create --name myEndpoint --profile-name myProfile --resource-group myResourceGroup --origin myOrigin
C. az storage account create --name myEndpoint --profile myProfile
D. az vm create --name myEndpoint --profile myProfile

Solution

  1. Step 1: Identify the correct Azure CLI command for endpoint creation

    The command to create a CDN endpoint is az cdn endpoint create with parameters for name, profile, resource group, and origin.
  2. Step 2: Eliminate incorrect commands

    The other options use commands for profile creation, storage account creation, and virtual machine creation, which are unrelated to endpoint creation.
  3. Final Answer:

    az cdn endpoint create --name myEndpoint --profile-name myProfile --resource-group myResourceGroup --origin myOrigin -> Option B
  4. Quick Check:

    Endpoint creation uses az cdn endpoint create [OK]
Hint: Use 'az cdn endpoint create' with profile and origin [OK]
Common Mistakes:
  • Using profile create command instead of endpoint create
  • Confusing storage or VM commands with CDN commands
  • Omitting required parameters like origin
3. Given an Azure CDN endpoint configured with origin mywebsite.azurewebsites.net, what happens when a user requests a file not yet cached by the CDN?
medium
A. The CDN fetches the file from the origin and caches it for future requests
B. The CDN returns a 404 error immediately
C. The CDN redirects the user to the origin URL
D. The CDN serves a default placeholder file

Solution

  1. Step 1: Understand CDN cache miss behavior

    When a requested file is not in the CDN cache, the CDN fetches it from the origin server.
  2. Step 2: Explain caching for future requests

    After fetching, the CDN caches the file to serve subsequent requests faster and reduce load on the origin.
  3. Final Answer:

    The CDN fetches the file from the origin and caches it for future requests -> Option A
  4. Quick Check:

    Cache miss = fetch + cache [OK]
Hint: Cache miss triggers origin fetch and caching [OK]
Common Mistakes:
  • Assuming CDN returns error on cache miss
  • Thinking CDN redirects to origin URL
  • Believing CDN serves placeholder files
4. You created an Azure CDN endpoint but users report stale content is served after you updated your origin. What is the most likely cause and fix?
medium
A. The CDN profile is deleted; recreate the profile
B. The origin server is down; restart the origin server
C. The endpoint URL is incorrect; update DNS settings
D. The CDN cache is not refreshed; purge the CDN endpoint cache

Solution

  1. Step 1: Identify cause of stale content

    CDNs cache content to improve speed, so updates at origin may not appear immediately due to cached copies.
  2. Step 2: Apply the fix by purging cache

    Purging the CDN endpoint cache forces the CDN to fetch fresh content from the origin on next requests.
  3. Final Answer:

    The CDN cache is not refreshed; purge the CDN endpoint cache -> Option D
  4. Quick Check:

    Stale content = cache purge needed [OK]
Hint: Purge CDN cache to update stale content [OK]
Common Mistakes:
  • Restarting origin when issue is cache
  • Recreating profile unnecessarily
  • Changing DNS when endpoint URL is correct
5. You want to design a scalable global content delivery system using Azure CDN. Which combination of Azure CDN features and configurations best supports low latency and high availability?
hard
A. Create multiple CDN endpoints in different regions under one profile; enable geo-filtering and custom domain HTTPS
B. Use a single CDN endpoint with default settings; rely on origin scaling
C. Create multiple CDN profiles with one endpoint each; disable caching to always fetch from origin
D. Use Azure Blob Storage directly without CDN; enable CDN only for static files

Solution

  1. Step 1: Understand global scalability needs

    Multiple CDN endpoints in different regions reduce latency by serving users from nearest edge locations.
  2. Step 2: Use features for availability and security

    Geo-filtering controls content delivery by region; custom domain HTTPS secures traffic and improves trust.
  3. Step 3: Evaluate other options

    Single endpoint or disabling caching reduces performance; multiple profiles add complexity without benefit; skipping CDN loses caching advantages.
  4. Final Answer:

    Create multiple CDN endpoints in different regions under one profile; enable geo-filtering and custom domain HTTPS -> Option A
  5. Quick Check:

    Multiple endpoints + geo-filter + HTTPS = scalable, low latency [OK]
Hint: Multiple endpoints + geo-filtering + HTTPS for global scale [OK]
Common Mistakes:
  • Using single endpoint for global users
  • Disabling caching reduces performance
  • Ignoring HTTPS security best practices