Locate your storage account and select it to display the account's Overview pane.
In the Overview pane, select the Capabilities tab. Next, select Static website to display the configuration page for the static website.
Select Enabled to enable static website hosting for the storage account.
In the Index document name field, specify a default index page (For example: index.html).
The default index page is displayed when a user navigates to the root of your static website.
In the Error document path field, specify a default error page (For example: 404.html).
The default error page is displayed when a user attempts to navigate to a page that does not exist in your static website.
Click Save to finish the static site configuration.
A confirmation message is displayed. Your static website endpoints and other configuration information are shown within the Overview pane.
You can enable static website hosting by using the Azure CLI.
First, open the Azure Cloud Shell, or if you've installed the Azure CLI locally, open a command console application such as Windows PowerShell.
If your identity is associated with more than one subscription, then set your active subscription to subscription of the storage account that will host your static website.
az account set --subscription <subscription-id>
Replace the <subscription-id> placeholder value with the ID of your subscription.
Replace the <storage-account-name> placeholder value with the name of your storage account.
Replace the <error-document-name> placeholder with the name of the error document that will appear to users when a browser requests a page on your site that does not exist.
Replace the <index-document-name> placeholder with the name of the index document. This document is commonly "index.html".
You can enable static website hosting by using the Azure PowerShell module.
Open a Windows PowerShell command window.
Verify that you have Azure PowerShell module Az version 0.7 or later.
Get-InstalledModule -Name Az -AllVersions | select Name,Version
Sign in to your Azure subscription with the Connect-AzAccount command and follow the on-screen directions.
Connect-AzAccount
If your identity is associated with more than one subscription, then set your active subscription to subscription of the storage account that will host your static website.
Replace the <error-document-name> placeholder with the name of the error document that will appear to users when a browser requests a page on your site that does not exist.
Replace the <index-document-name> placeholder with the name of the index document. This document is commonly "index.html".
The following instructions show you how to upload files by using the Azure portal. You could also use AzCopy, PowerShell, CLI, or any custom application that can upload files to the $web container of your account. For a step-by-step tutorial that uploads files by using Visual Studio code, see Tutorial: Host a static website on Blob Storage.
In the Azure portal, navigate to the storage account containing your static website. Select Containers in the left navigation pane to display the list of containers.
In the Containers pane, select the $web container to open the container's Overview pane.
In the Overview pane, select the Upload icon to open the Upload blob pane. Next, select the Files field within the Upload blob pane to open the file browser. Navigate to the file you want to upload, select it, and then select Open to populate the Files field. Optionally, select the Overwrite if files already exist checkbox.
If you intend for the browser to display the contents of file, make sure that the content type of that file is set to text/html. To verify this, select the name of the blob you uploaded in the previous step to open its Overview pane. Ensure that the value is set within the CONTENT-TYPE property field.
Note
This property is automatically set to text/html for commonly recognized extensions such as .html. However, in some cases, you'll have to set this yourself. If you don't set this property to text/html, the browser will prompt users to download the file instead of rendering the contents. This property can be set in the previous step.
Upload objects to the $web container from a source directory.
This example assumes that you're running commands from Azure Cloud Shell session.
az storage blob upload-batch -s <source-path> -d '$web' --account-name <storage-account-name>
Note
If the browser prompts users users to download the file instead of rendering the contents, you can append --content-type 'text/html; charset=utf-8' to the command.
Replace the <storage-account-name> placeholder value with the name of your storage account.
Replace the <source-path> placeholder with a path to the location of the files that you want to upload.
Note
If you're using a location installation of Azure CLI, then you can use the path to any location on your local computer (For example: C:\myFolder.
If you're using Azure Cloud Shell, you'll have to reference a file share that is visible to the Cloud Shell. This location could be the file share of the Cloud share itself or an existing file share that you mount from the Cloud Shell. To learn how to do this, see Persist files in Azure Cloud Shell.
Upload objects to the $web container from a source directory.
If the browser prompts users users to download the file instead of rendering the contents, you can append -Properties @{ ContentType = "text/html; charset=utf-8";} to the command.
Replace the <path-to-file> placeholder value with the fully qualified path to the file that you want to upload (For example: C:\temp\index.html).
Replace the <blob-name> placeholder value with the name that you want to give the resulting blob (For example: index.html).
Find the website URL
You can view the pages of your site from a browser by using the public URL of the website.
In the pane that appears beside the account overview page of your storage account, select Static Website. The URL of your site appears in the Primary endpoint field.
Find the public URL of your static website by using the following command:
az storage account show -n <storage-account-name> -g <resource-group-name> --query "primaryEndpoints.web" --output tsv
Replace the <storage-account-name> placeholder value with the name of your storage account.
Replace the <resource-group-name> placeholder value with the name of your resource group.
Find the public URL of your static website by using by using the following command:
Replace the <resource-group-name> placeholder value with the name of your resource group.
Replace the <storage-account-name> placeholder value with the name of your storage account.
Enable metrics on static website pages
Once you've enabled metrics, traffic statistics on files in the $web container are reported in the metrics dashboard.
Click Metrics under the Monitor section of the storage account menu.
Note
Metrics data are generated by hooking into different metrics APIs. The portal only displays API members used within a given time frame in order to only focus on members that return data. In order to ensure you're able to select the necessary API member, the first step is to expand the time frame.
Click on the time frame button, choose a time frame, and then click Apply.
Select Blob from the Namespace drop down.
Then select the Egress metric.
Select Sum from the Aggregation selector.
Click the Add filter button and choose API name from the Property selector.
Check the box next to GetWebContent in the Values selector to populate the metrics report.
Note
The GetWebContent checkbox appears only if that API member was used within a given time frame. The portal only displays API members used within a given time frame in order to only focus on members that return data. If you can't find a specific API member in this list, expand the time frame.