Documentation: Static website hosting
This article explains how to host a static website on Azure Blob Storage. Azure Blob Storage offers a cost-effective way to host static content (HTML, CSS, JavaScript, and images) directly from a storage account. This approach is ideal for static websites, gaming websites, or any site where content doesn't change frequently.
Static website hosting is a feature that can be enabled on an Azure Storage account. When enabled, the storage account creates a special container named $web for storing website files. You can then point your custom domain or a direct Azure URL to this container to serve your static content.
Note: Static website hosting is only supported on Storage accounts created with the StorageV2 (general-purpose v2) or BlobStorage account types.
You can enable static website hosting on a new or existing Azure Storage account. Ensure the account type is StorageV2 or BlobStorage.
To create a new account with the Azure portal:
StorageV2 (general-purpose v2) or BlobStorage).Once your storage account is created, navigate to its overview page in the Azure portal. Then:
index.html). This is the default page served when a user navigates to your website's root.404.html). This page is served when an error occurs, such as a requested file not being found.After saving, Azure will automatically create a blob container named $web. You'll also see the Primary endpoint for your static website displayed on this page. This is the URL you'll use to access your website.
Upload your website's static files (HTML, CSS, JavaScript, images, etc.) to the $web container.
You can use various tools to upload your files:
$web container, then click Upload.az storage blob upload-batch command for uploading multiple files.Set-AzStorageBlobContent for uploading.Ensure your main index page (e.g., index.html) is at the root of the $web container.
For the static website feature to work, the $web container must be publicly accessible. Azure automatically configures this for the $web container when static website hosting is enabled. You do not need to change the public access level of the $web container.
Once your files are uploaded, you can access your static website using the Primary endpoint URL provided in the static website settings of your storage account. For example:
https://yourstorageaccountname.web.core.windows.net/
To use your own domain name (e.g., www.yourdomain.com) instead of the Azure endpoint, you'll need to configure a custom domain.
www) to the primary endpoint of your static website.Tip: Using Azure CDN is crucial for production environments. It provides caching at edge locations worldwide, significantly reducing latency for your users.
$web container. Verify the file name spelling and case.$web container's public access level is correctly set (Azure manages this automatically).By following these steps, you can effectively leverage Azure Blob Storage to host your static websites with high availability and scalability.