Skip to main content

Configuring CDN Endpoints in Microsoft Azure

Hands-On Lab

 

Photo of Gary McLeary

Gary McLeary

Azure Training Architect I in Content

Length

01:00: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

Content Delivery Networks improve performance for the delivery of content to customers who have data centers in different locations throughout the world. In this hands-on lab, we will configure a CDN within the Azure Portal.

First, we will create a CDN profile. Once the CDN profile is created, we can create the CDN endpoint.

Completing this lab will give us 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 an organization's needs.

UPDATE: Use West US for this lab.

The Scenario

Our organization has all of it's Azure resources in the US. But they're getting ready to expand globally and start offering products to customers in Australia. But customers over there will get slower service because of where our resources are. We've got to set up a CDN to address this. This way anyone in the world will be somewhere near one of the CDN endpoints, and access our content quickly.

Logging In

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

Create a New CDN Profile and CDN Endpoint

  • Log in to the Azure Portal.
  • Create a resource by clicking on the icon in the top left corner of the Portal.
  • In the search box, type in CDN.
  • Select CDN (Publisher:Microsoft).
  • Click Create.
  • Use CDN-FirstNameLastName as the profile name (e.g. CDN-JohnSmith):
    • Note: If CDN-JohnSmith is in use, use an alternate name like CDN-JohnSmith-Date
  • Leave Subscription set to whatever is in there by default.
  • Select Content_DeliveryNetwork... as the Resource Group.
  • Use Standard Akamai as the Pricing Tier:
    • Do not use the Verizon or Microsoft pricing tiers.
  • Click on the checkbox that says Create a new CDN endpoint now.
  • Use CDN-FirstNameLastName as the CDN endpoint name, or a variation of CDN-FirstNameLastName if that name is already in use.
  • Use Storage as the Origin type.
  • Click the drop-down box and select the Origin hostname that appears (it should start with azurelabwwk)
  • Click Create

Explore the Azure CDN Caching Rules Page

  • Go to All Resources on the left-hand pane.
  • Click on the resource that shows Endpoint as the type (there should only be 1 endpoint).
  • Click on Caching Rules under Settings and review the different areas.

Set Custom Caching Rules

  • Go to the Custom Caching Rules section, and set one up with these values:
    • Match Condition: File extension(s)
    • Match values: Type jpg, png, gif
    • Caching Behavior: Override
    • Days: 1
  • Leave all of the other fields as they are and click Save.

Test Content Delivery Network

  • Go to Storage Accounts within the Azure Portal (left pane).
  • Click on the existing Storage Account.
  • Click on Blobs
  • Create a container by clicking on the + Container button:
    • Give it a Name of images
    • Set the Public access level to Container (anonymous read access for containers and blobs)
  • Open a separate browser window and download the image we'll need in the next step from https://github.com/GaryMcLeary/70-533-Files/blob/master/TLS%20scan.PNG.
  • Back in the Azure portal, click on the images container, then click on the option to Upload.
  • Upload the image we downloaded from GitHub.
  • Click Upload.
  • Click on the newly uploaded image and we should see the URL in the new screen. Copy that URL and go to it in a web browser.
  • Now let's go back to the Azure Portal, and into All resources.
  • Click on the resource that has the type Endpoint.
  • Copy the Endpoint hostname and add imagesTLS scan.png:
  • Go to the endpoint URL to make sure you see the same image.

Updating the Image

Purge CDN Cache

  • Go back to All Resources.
  • Click on Resource with the type CDN Profile.
  • Click Purge.
  • Select our endpoint from the dropdown.
  • Enter / as a Content path, then click the blue Purge button at the bottom of the screen.
  • Test the CDN URL to see if you now see the rotated image.
  • If you see the rotated image, you can stop here.

  • If you do not see the rotated image, go back to the Storage Account, and navigate to Blobs.
  • Add an additional container labeled image (make sure the newly created container shows Annonymous read access for containers and blobs)
  • Click OK.
  • Upload the newly created image to this new container (image).
  • Go back to All Resources.
  • Click on Resource with the type of Endpoint.
  • Click on Origin.
  • Leave all of the existing settings as they, are except for path. Put /image as the path and click Save.
  • Now we can 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.
  • You should now see the updated image.

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!