- Lab
- A Cloud Guru
Hosting a Static Website with Azure Blob Storage
Azure Storage Blobs are a great tool for storing all kinds of data, but they can also be used to serve that data anywhere in the world. As such, Blobs can be used to host and serve a simple, static website. In this lab, you will have the opportunity to work with Azure Storage Blobs by using them to host a static website. You will create and configure the necessary storage account, and you will upload static files to Blob storage. When you finish, you will be able to view the static website in your browser.
Path Info
Table of Contents
-
Challenge
Create a storage account to host the static website.
- Click + Add to create a new resource.
- Search for and select Storage Account.
- For Resource Group, select the existing resource group if it is not already selected.
- Enter a Storage account name that begins with staticsite. You may need to add some characters at the end of the name to make it unique.
- Click Review + Create, then Create.
-
Challenge
Configure the storage account for static site hosting.
- Wait for your storage account to finish being created. When viewing the resource group, you can click Refresh. When your storage account appears in the list, it has been created.
- Click on your storage account, then click Static Website on the left side of the storage account pane.
- Click Enabled to enable static website hosting for the storage account.
- For Index document name, enter
index.html
. - Click Save.
-
Challenge
Upload the static site files.
- Log in to Azure Cloud Shell at https://shell.azure.com.
- Select Bash, then advanced settings. Select use existing for all three fields, and enter cloudshell for the container.
- Get the key for the storage account. Note that you can find the resource group name in the Azure portal. The storage account name is the name of the storage account you created earlier.
export AZURE_STORAGE_ACCOUNT="<storage account name>" export RESOURCE_GROUP="<resource group name>" az storage account keys list --account-name $AZURE_STORAGE_ACCOUNT --resource-group $RESOURCE_GROUP --output table
- Set an environment variable containing the storage account key.
export AZURE_STORAGE_KEY="<key>"
- Clone the lab resources repository from GitHub and switch to the static site directory.
git clone https://github.com/linuxacademy/content-azurestoragedd-lab-resources.git cd content-azurestoragedd-lab-resources/satt-static-site/
- Upload the static site files as blobs within the
$web
container.
az storage blob upload-batch -d "\$web" -s .
- In Azure portal, navigate back to the static site storage account and select Static Website again. This page contains a URL under Primary Endpoint. Copy this URL and access it in a new tab.
You should see the website for Store All The Things!
What's a lab?
Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.
Provided environment for hands-on practice
We will provide the credentials and environment necessary for you to practice right within your browser.
Guided walkthrough
Follow along with the author’s guided walkthrough and build something new in your provided environment!
Did you know?
On average, you retain 75% more of your learning if you get time for practice.