Ask Learn Preview
Please sign in to use this experience.
Sign inThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
This module requires a sandbox to complete. A sandbox gives you access to free resources. Your personal subscription will not be charged. The sandbox may only be used to complete training on Microsoft Learn. Use for any other reason is prohibited, and may result in permanent loss of access to the sandbox.
Microsoft provides this lab experience and related content for educational purposes. All presented information is owned by Microsoft and intended solely for learning about the covered products and services in this Microsoft Learn module.
Before we explore Content Delivery Networks, let's deploy a static website in Azure Storage to use throughout the module.
Start by creating a new storage account to host a static site. When we're finished, you can access this site through the content delivery network.
The free sandbox allows you to create resources in a subset of the Azure global regions. Select a region from this list when you create resources:
Install the storage-preview
extension by executing the following command in Azure Cloud Shell. This Azure CLI extension is needed to manage static websites from the CLI. Run the following command in the Cloud Shell terminal window on the right:
az extension add --name storage-preview
Run these commands in the Cloud Shell to set up a few shell variables. Use these variables throughout this module to create items such as a storage account name. Replace <location>
with one of the locations in the region list.
STORAGE_ACCOUNT_NAME="cdnsitestorage$RANDOM" \
RESOURCE_GROUP=[sandbox resource group name] \
LOCATION=<location>
Run this command in the Cloud Shell to create the storage account.
az storage account create \
--name $STORAGE_ACCOUNT_NAME \
--resource-group $RESOURCE_GROUP \
--location $LOCATION \
--sku Standard_LRS \
--kind StorageV2
In the output, find the "primaryEndpoints"
web url, copy it, and open the link in a web browser. The page that opens indicates that The requested content doesn't exist. Keep this tab open; we're going to deploy our static content and then refresh the page.
In the Cloud Shell, run the following command to enable static website hosting on the storage account.
az storage blob service-properties update \
--account-name $STORAGE_ACCOUNT_NAME \
--static-website \
--404-document 404.html \
--index-document index.html
At the end of the output, you should see the entry:
"staticWebsite": {
"enabled": true,
"errorDocument_404Path": "404.html",
"indexDocument": "index.html"
}
Switch to the browser tab displaying the static website and refresh it. You see a message that the requested content doesn't exist.
To upload the website files, execute the following commands:
git clone https://github.com/MicrosoftDocs/mslearn-create-cdn-static-resources-blob-storage source
Navigate to the source/website-files
folder
cd source/website-files
Then upload those files to the $web blob storage container.
az storage blob upload-batch -s . -d \$web --account-name $STORAGE_ACCOUNT_NAME
Switch to the website you opened earlier and refresh the page (press F5). You see the landing page and an image.
Please sign in to use this experience.
Sign in