If you want to optimize your content delivery network endpoint for dynamic site acceleration (DSA), you should use the content delivery network portal to create your profile and endpoint. With DSA optimization, the performance of web pages with dynamic content is measurably improved. For instructions about how to optimize a content delivery network endpoint for DSA from the content delivery network portal, see content delivery network endpoint configuration to accelerate delivery of dynamic files.
Otherwise, if you don't want to optimize your new endpoint, you can use the web app portal to create it by following the steps in the next section. For Azure CDN from Edgio profiles, you can't change the optimization of a content delivery network endpoint after it has been created.
Create a content delivery network profile and endpoint
In the left navigation, select App Services, and then select the app that you created in the static HTML quickstart.
In the App Service page, in the Settings section, select Networking > Azure CDN.
In the Azure Content Delivery Network page, provide the New endpoint settings as specified in the table.
Setting
Suggested value
Description
content delivery network profile
myCDNProfile
A content delivery network profile is a collection of content delivery network endpoints with the same pricing tier.
Pricing tier
Microsoft content delivery network (classic)
The pricing tier specifies the provider and available features.
content delivery network endpoint name
Any name that is unique in the azureedge.net domain
You access your cached resources at the domain <endpointname>.azureedge.net.
Select Create to create a content delivery network profile.
Azure creates the profile and endpoint. The new endpoint appears in the Endpoints list, and when it's provisioned, the status is Running.
Test the content delivery network endpoint
Because it takes time for the registration to propagate, the endpoint isn't immediately available for use:
For Azure CDN Standard from Microsoft (classic) profiles, propagation usually completes in 10 minutes.
For Azure CDN Standard from Edgio and Azure CDN Premium from Edgio profiles, propagation usually completes within 90 minutes.
The sample app has an index.html file and css, img, and js folders that contain other static assets. The content paths for all of these files are the same at the content delivery network endpoint. For example, both of the following URLs access the bootstrap.css file in the css folder:
You see the same page that you ran earlier in an Azure web app. Azure Content Delivery Network has retrieved the origin web app's assets and is serving them from the content delivery network endpoint
To ensure that this page is cached in the content delivery network, refresh the page. Two requests for the same asset are sometimes required for the content delivery network to cache the requested content.
The content delivery network periodically refreshes its resources from the origin web app based on the time to live (TTL) configuration. The default TTL is seven days.
At times you might need to refresh the content delivery network before the TTL expiration; for example, when you deploy updated content to the web app. To trigger a refresh, manually purge the content delivery network resources.
In this section of the tutorial, you deploy a change to the web app and purge the content delivery network to trigger the content delivery network to refresh its cache.
Deploy a change to the web app
Open the index.html file and add - V2 to the H1 heading, as shown in the following example:
<h1>Azure App Service - Sample Static HTML Site - V2</h1>
Commit your change and deploy it to the web app.
git commit -am "version 2"
git push azure main
Once deployment has completed, browse to the web app URL to see the change.
http://<appname>.azurewebsites.net/index.html
If you browse to the content delivery network endpoint URL for the home page, you don't see the changes because the cached version in the content delivery network hasn't expired yet.
http://<endpointname>.azureedge.net/index.html
Purge the content delivery network in the portal
To trigger the content delivery network to update its cached version, purge the content delivery network.
In the portal left navigation, select Resource groups, and then select the resource group that you created for your web app (myResourceGroup).
In the list of resources, select your content delivery network endpoint.
At the top of the Endpoint page, select Purge.
Enter the content paths you want to purge. You can pass a complete file path to purge an individual file, or a path segment to purge and refresh all content in a folder. Because you changed index.html, ensure that is in one of the paths.
At the bottom of the page, select Purge.
Verify that the content delivery network is updated
Wait until the purge request finishes processing, which is typically a couple of minutes. To see the current status, select the bell icon at the top of the page.
When you browse to the content delivery network endpoint URL for index.html, you see the V2 that you added to the title on the home page, which indicates that the content delivery network cache has been refreshed.
Azure Content Delivery Network returns the current web app content, which includes V2 in the heading.
To ensure that this page is cached in the content delivery network, refresh the page.
Open index.html, change V2 to V3, then deploy the change.
git commit -am "version 3"
git push azure main
In a browser, go to the content delivery network endpoint URL with a new query string, such as q=2. Azure Content Delivery Network gets the current index.html file and displays V3. However, if you navigate to the content delivery network endpoint with the q=1 query string, you see V2.
In the preceding steps, you created Azure resources in a resource group. If you don't expect to need these resources in the future, delete the resource group by running the following command in the Cloud Shell:
az group delete --name myResourceGroup
This command may take a minute to run.
Next steps
What you learned:
Create a content delivery network endpoint.
Refresh cached assets.
Use query strings to control cached versions.
Learn how to optimize content delivery network performance in the following articles:
Learn how to create and utilize a Content Delivery Network (CDN) within Azure to host commonly used assets, such as images in a website. The module covers Azure CDN and uses Blob Storage as an underlying storage model for stable or nonvolatile data.
Build end-to-end solutions in Microsoft Azure to create Azure Functions, implement and manage web apps, develop solutions utilizing Azure storage, and more.