In this guide, we will explain how to host static websites using Azure Blob Storage. Azure Blob Storage offers a streamlined solution for serving static content—HTML, CSS, JavaScript, and image files—without the complexity of managing full web servers. By leveraging a dedicated container named $web, Azure Blob Storage simplifies static website hosting. When you enable the static website feature, Azure automatically creates the $web container. All the static files you upload to this container, such as HTML, CSS, and JavaScript, are immediately available on the internet. This setup removes the need for additional infrastructure like virtual machines or App Services and integrates well with serverless architectures. For instance, you can easily pair your static content with Azure Functions to handle backend operations like form submissions or email processing. Mapping the auto-generated URL (e.g., https://youraccountname.blob.core.windows.net) to a custom domain is also supported. You can provide a memorable domain name like www.kodekloud.com by updating your DNS settings to point to the Azure Blob Storage endpoint.Documentation Index
Fetch the complete documentation index at: https://notes.kodekloud.com/llms.txt
Use this file to discover all available pages before exploring further.

Benefits & Limitations of Static Website Hosting
One major benefit is the ease of setup. With just a few clicks in the Azure portal, you can activate the static website feature without dealing with server management. However, there are a few limitations to consider:- Custom HTTP Headers: Azure Blob Storage does not natively support configuring custom HTTP headers (e.g., Content Security Policy, X-Frame-Options, or cache control). Although integrating Azure CDN can serve as a workaround, it introduces additional complexity and potential cost.
- Authentication and Authorization: Built-in static website hosting does not offer features for authentication or authorization. To restrict access (for example, to admin or premium sections), you need to integrate services like Microsoft Entra ID or Azure AD.

Setting Up a Static Website
Follow these steps to create a static website using Azure Blob Storage in the Azure portal:1. Enable Static Website Hosting
- Open your storage account in the Azure portal.
- In the menu (located above “Lifecycle management”), select “Static website” and enable the feature.
- Enter the index document name (commonly
index.html). If required, specify an error document (e.g.,error.html).

2. Configure Container Access
- Navigate to the storage account’s containers and find the newly created $web container.
- By default, the container is private. Click on it, then select “Change access level” and choose “blob” to allow anonymous public access.

3. Upload Your Website Files
Upload your HTML, CSS, JavaScript, and image files directly into the $web container. There are multiple methods to do this:- Azure Storage Explorer
- Azure Portal: Use the “Upload” option within the $web container.
- AzCopy: A command-line tool ideal for transferring files.


4. Use AzCopy to Transfer Files
Open your terminal to verify that AzCopy is installed. Since you are already logged in, copy the files from your local directory (e.g., “web-template”) to thesymbol in$web` to avoid variable substitution issues in the terminal.
To escape the
$ symbol in the terminal command, use a backslash (\).
5. Test the Static Website
- Locate the
index.htmlblob and inspect its properties. - Click on the blob, copy its URL, and paste it into a web browser. The static website should load as expected.


6. Associate Custom Domains & Additional Services
Azure Blob Storage allows you to map a custom domain to your static website. You can also leverage services like Azure Front Door or a CDN for multi-region deployment and content caching.- To configure a custom domain, navigate to the networking settings in your storage account and follow the instructions to set up a CNAME record.

