Host a static website in Azure Storage
This article shows you how to enable static website hosting by using the Azure portal, the Azure CLI, or PowerShell.
Enable static website hosting
Static website hosting is a feature that you have to enable on the storage account.
Sign in to the Azure portal to get started.
Locate your storage account and display the account overview.
Select Static website to display the configuration page for static websites.
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. The Azure portal now displays your static website endpoint.
These instructions show you how to upload files by using the version of Storage Explorer that appears in the Azure portal. However, you can also use the version of Storage Explorer that runs outside of the Azure portal. You could 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.
Select Storage Explorer (preview).
Expand the BLOB CONTAINERS node, and then select the $web container.
Choose the Upload button to upload files.
If you intend for the browser to display the contents of file, make sure that the content type of that file is set to
Storage Explorer automatically sets this property to
text/htmlfor 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. To set this property, right-click the file, and then click Properties.
Find the website URL by using the Azure portal
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.
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.
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.
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.
- Learn how to configure a custom domain with your static website. See Map a custom domain to an Azure Blob Storage endpoint.
Učitavanje povratnih informacija...