Skip to main content

Deploying a Static Website Using Containers on Azure



Requirements

The Nautilus DevOps team has been tasked with creating an internal information portal for public access. As part of this project, they need to host a static website on Azure using an Azure Storage account. The Storage account must be configured for public access to allow external users to access the static website directly via the Azure Storage URL.

Task Requirements:

  1. Create an Azure Storage account named nautiluswebstorage30202 in an existing resource group.
  2. Configure the Storage account for static website hosting with index.html as the index document.
  3. Allow public access to the static website so that the website is publicly accessible.
  4. Upload the index.html file from the /root/ directory of the Azure client host to the Storage account's $web container.
  5. Verify that the website is accessible directly through the Azure Storage static website URL.

Note

Static website content is served from the special $web container endpoint, not from VM-hosted web services.

Prerequisites

  • Azure CLI installed and authenticated.
  • Existing resource group available.
  • /root/index.html present on the client host.

Steps

RG=$(az group list --query "[?contains(name, 'kml')].name" --output tsv)
SA="nautiluswebstorage30202"
LOCATION="eastus"
INDEX_FILE="index.html"
FILE_PATH="/root/${INDEX_FILE}"

az storage account create \
--name "$SA" \
--resource-group "$RG" \
--location "$LOCATION" \
--sku Standard_LRS \
--kind StorageV2

az storage blob service-properties update \
--account-name "$SA" \
--static-website \
--index-document "$INDEX_FILE"

az storage blob upload \
--account-name "$SA" \
--container-name '$web' \
--name "$INDEX_FILE" \
--file "$FILE_PATH" \
--auth-mode login

URL=$(az storage account show \
--name "$SA" \
--resource-group "$RG" \
--query primaryEndpoints.web -o tsv)

echo "$URL"

Verification

  • Verify static website settings:
    • az storage blob service-properties show --account-name "$SA" --query staticWebsite
  • Verify index.html blob exists in $web:
    • az storage blob show --account-name "$SA" --container-name '$web' --name index.html --auth-mode login --query name -o tsv
  • Verify website endpoint responds:
    • curl "$URL"

Resources