What is Static Website Hosting?
A static website consists of files that are served exactly as-is — HTML, CSS, JavaScript, images. There's no server-side processing, no database queries, no backend logic executed on the server. The browser downloads the files and runs everything client-side.
Modern frontend frameworks like React and Vue produce static builds — a folder of HTML, JS, and CSS files that can be served from any web server or object storage service like Azure Blob Storage.
Enabling Static Website Hosting
Via Azure Portal
- Go to your Storage Account
- In the left menu → Data management → Static website
- Toggle to Enabled
- Set Index document name →
index.html - Set Error document path →
404.html(optional) - Click Save
- Azure creates the
$webcontainer and shows you the endpoint URL
Via Azure CLI
az storage blob service-properties update \
--account-name mystorageaccount2026 \
--static-website \
--index-document index.html \
--404-document 404.html \
--auth-mode login
The $web Container
When you enable static website hosting, Azure automatically creates a special container named $web. All website files must be uploaded to this container. The container is publicly readable — any file in $web can be accessed via the static website endpoint.
Deploying Your Website
# Build your frontend app first
# npm run build (creates a /dist or /build folder)
# Upload all files to $web container
az storage blob upload-batch \
--account-name mystorageaccount2026 \
--destination '$web' \
--source ./dist \
--auth-mode login
# Set correct content types (important for JS/CSS)
# Azure CLI usually handles this automatically
# Delete old files not in the new build (clean deploy)
az storage blob upload-batch \
--account-name mystorageaccount2026 \
--destination '$web' \
--source ./dist \
--overwrite \
--auth-mode login
The Static Website Endpoint
After enabling, your website is accessible at a URL like:
https://[accountname].z[N].web.core.windows.net
# Example:
https://mystorageaccount2026.z13.web.core.windows.net
Note: The zone number (z13, z30, etc.) depends on your region. This is different from the blob storage endpoint.
Custom Error Pages
Set a custom 404 page to handle requests for files that don't exist. This is particularly important for single-page applications (SPAs) where the router handles navigation — all routes should serve index.html.
index.html. This ensures all routes (like /about, /products/123) serve the app, and the JS router handles the navigation client-side.
Limitations
Blob static hosting has some important limitations:
- No custom domain with HTTPS out of the box — The default endpoint uses Azure's domain. Custom domain requires Azure CDN.
- No server-side logic — Only static files. No PHP, Node.js, Python. Use Azure Functions for APIs.
- No HTTP headers customisation — Can't add custom Cache-Control, CORS headers, etc. without CDN.
- No HTTP to HTTPS redirect — Requires CDN to enforce HTTPS.
- Single region — The storage account is in one region. Use CDN to add global distribution.
Adding CDN for Custom Domain + HTTPS
To use a custom domain (like www.yoursite.com) with HTTPS, you add Azure CDN in front of your static website:
- Create an Azure CDN profile and endpoint pointing to your static website origin
- Add your custom domain to the CDN endpoint
- Enable HTTPS (free managed certificate from CDN)
- Update your DNS to point to the CDN endpoint
See the Azure CDN with Storage page for the full setup guide.
Blob Hosting vs Azure Static Web Apps
| Feature | Blob Static Hosting | Azure Static Web Apps |
|---|---|---|
| Setup | Manual | GitHub/DevOps integrated CI/CD |
| Custom domain + HTTPS | Requires CDN | Built-in (free SSL) |
| API integration | Separate Azure Functions | Built-in managed Functions |
| Staging environments | Separate storage accounts | Built-in preview environments per PR |
| Auth integration | Manual | Built-in (GitHub, Azure AD, etc.) |
| Cost | ~₹0.10–1/month (storage only) | Free tier available; paid from ~₹700/month |
| Best for | Simple sites, full manual control | Modern web apps with CI/CD and APIs |