Integrating Azure CDN With Web Apps
Integrating Azure CDN With Web Apps
Integrating Azure CDN With Web Apps
Publish: Code
Click on Extensions -> Search for “Azure sign in” -> Select Azure Account and click on Install button
Click on Extensions -> Search for “Azure App Service” -> Select Azure App Service and click on Install
button
Step 12: First we need to Sign with Azure account in Visual Studio Code
View Menu -> Command Palette…
Automatic browser will open with Azure login. Enter Azure Credentials
Within few second it will load as below: You are signed in now and can close this page.
Right side bottom status available. Wait for few seconds to deploy on Azure
Open another Browser and paste CDN Endpoint hostname URL. Also add /index.html and run site
Also try with different files such as jpg, js, css
/css/bootstrap.css
Replace with
Now review both URLs: Site address and CDN Endpoint address
Normal site updated with V2 but CDN Endpoint site not updated.
Task 4: Purge the CDN
We can resolve this issue by below functionality
The CDN 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 CDN before the TTL
expiration; for example, when you deploy updated content to the web app. To trigger a refresh,
manually purge the CDN resources.
Step 23: Enter Content path details and click on Purge option
Content path
/index.html
/img/
/css/
/js/
Step 24: Now refresh CDN Endpoint URL. Changes will be done.
Task 5: Query String to version Content
The first option is the default, which means there is only one cached version of an asset regardless of
the query string in the URL.
http://<endpointname>.azureedge.net/index.html ?q=1
Step 27: Once again navigate to Visual Studio Code and update version from v2 to v3.
<h1>Azure CDN Demo Site – v2</h1>
http://cdnwebdemo.azureedge.net/index.html?q=2 -> q=2 is new, so the latest web app contents are
retrieved and returned (v3)
Task 6: Restrict Azure CDN Content by Country/Region
When a user requests your content, by default, the content is served regardless of the location
of the user making the request. However, in some cases, you may want to restrict access to your
content by country/region. With the geo-filtering feature, you can create rules on specific paths
on your CDN endpoint to allow or block content in selected countries/regions.
Path: /img/
Action: Block