Skip to main content

Configuring CDN Endpoints in Microsoft Azure

Hands-On Lab

 

Photo of joel

joel

Training Architect

Length

01:45:00

Difficulty

Intermediate

In this Hands-On Lab, we will configure a Content Delivery Network (CDN) within the Azure Portal. This is an important procedure as it helps improve performance for the delivery of content to customers who have data centers in different locations throughout the world.<br>

We will first create a CDN profile. Once the CDN profile is created, we can create the CDN endpoint.<br>

After completing this lab, you will have a better understanding of how to use a CDN, the benefits of using a CDN, and also the different caching rules that are available to optimize the CDN so it meets your organization's needs.

UPDATE: Use West US for this lab.

What are Hands-On Labs?

Hands-On Labs are scenario-based learning environments where learners can practice without consequences. Don't compromise a system or waste money on expensive downloads. Practice real-world skills without the real-world risk, no assembly required.

Configuring CDN Endpoints in Microsoft Azure

Introduction

In this hands-on lab, we will configure a content delivery network (CDN) within the Azure Portal. This is an important procedure as it helps improve performance for the delivery of content to customers who have data centers in different locations throughout the world. We will first create a CDN profile. Once the CDN profile is created, we can create the CDN endpoint. After completing this lab, you will have a better understanding of how to use a CDN, the benefits of using a CDN, and the different caching rules available to optimize the CDN so it meets your organization's needs.

Solution

Use the credentials provided on the hands-on lab overview page to log into the Azure portal.

Download the TLS scan.png image file we need for the lab.

Create a New CDN Profile and CDN Endpoint

  1. Log in to the Azure Portal.
  2. In the search box at the top, type in CDN.
  3. Under Marketplace, select CDN.
  4. Set the following values:
    • Name: CDN-FirstNameLastName-Date (e.g., "CDN-JohnSmith-040220")
    • Subscription: Leave default
    • Resource group: Select the one listed
    • Pricing tier: Standard Akamai
    • Create a new CDN endpoint now: Check
    • CDN endpoint name: CDN-FirstNameLastName-Date (e.g., "CDN-JohnSmith-040220")
    • Origin type: Storage
    • Origin hostname: Select the one listed
  5. Click Create. It will take a few minutes for the CDN profile and endpoint to finish being created.

Explore the Azure CDN Caching Rules Page

  1. Navigate to All Resources.
  2. Once the CDN profile and endpoint are listed, click the resource that shows Endpoint as the type.
  3. Click Caching rules.

Set Custom Caching Rules

  1. In the Custom caching rules section, set the following values:
    • Match condition: File extension(s)
    • Match values: jpg, png, gif
    • Caching behavior: Override
    • Days: 1
  2. Leave all the other fields as they are, and click Save at the top.

Test Content Delivery Network

  1. Click the hamburger menu icon in the upper-left corner, and then select Storage accounts.
  2. Click the listed storage account.
  3. Click on Containers.
  4. Click + Container and set the following values:
    • Name: images
    • Public access level: Container (anonymous read access for containers and blobs)
  5. Click Create.
  6. Click the images container.
  7. Click Upload.
  8. Upload the TLS scan.png image we downloaded earlier from GitHub.
  9. Click Upload.
  10. Click on the newly uploaded image and we should see the URL in the new screen. Copy that URL and paste it into a new browser tab.
  11. In the Azure Portal, navigate to All resources.
  12. Click on the resource that has the type Endpoint.
  13. Copy the Endpoint hostname and add /images/TLS scan.png:
  14. Go to the endpoint URL to make sure you see the same image.

Update the Image

  1. Click the hamburger menu icon in the upper-left corner, and then select Storage accounts.
  2. Click the listed storage account.
  3. Click on Containers.
  4. Click images.
  5. Click the ... to the right of the image name.
  6. Select Delete.
  7. In the dialog, click OK.
  8. Download a new image, saving it as TLS scan.png.
  9. Upload the new image we just downloaded from GitHub.
  10. Once the image is uploaded, select it.
  11. Copy its URL and paste it into a new browser tab. It should be rotated.
  12. Refresh the CDN URL.

Purge CDN Cache

  1. Navigate to All Resources.
  2. Click the CDN profile resource.
  3. Click Purge.
  4. Select your endpoint from the dropdown.
  5. Enter / as a Content path.
  6. Click the blue Purge button at the bottom.
  7. Refresh the CDN URL to see if you now see the rotated image.
  8. If you see the rotated image, you can stop here.

  1. If you do not see the rotated image, navigate back to our storage account.
  2. Click Containers.
  3. Click + Container.
  4. Give it the name "image".
  5. Set its Public access level to Container (anonymous read access for containers and blobs).
  6. Click Create.
  7. Upload the new image to this new container (image).
  8. Go back to All resources.
  9. Click on the resource with the type of Endpoint.
  10. Click on Origin.
  11. Enter "/image" as the Origin path.
  12. Leave the rest of the existing settings as they are, and click Save.
  13. Go back to the CDN URL, but this time without /image(s). It will be similar to this URL: https://cdn-linuxcademy.azureedge.net/TLS%20scan.png.
  14. You should now see the updated image. Give it a few minutes if you don't — it may take up to five minutes for it to show up correctly.

Conclusion

We've managed to set up a CDN and tested to see if it was working properly by uploading some files and playing with cache settings. Congratulations!