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.
Successfully complete this lab by achieving the following learning objectives:
- 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.
- 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
- Click Save.
- 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.
- 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
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!