您现在访问的是微软AZURE全球版技术文档网站,若需要访问由世纪互联运营的MICROSOFT AZURE中国区技术文档网站,请访问 https://docs.azure.cn.

在 Azure 存储中托管静态网站Host a static website in Azure Storage

可以直接从 Azure 存储 GPv2 帐户中的容器提供静态内容(HTML、CSS、JavaScript 和映像文件)。You can serve static content (HTML, CSS, JavaScript, and image files) directly from a container in an Azure Storage GPv2 account. 若要了解详细信息,请参阅Azure 存储中的静态网站托管To learn more, see Static website hosting in Azure Storage.

本文介绍如何使用 Azure 门户、Azure CLI 或 PowerShell 启用静态网站托管。This article shows you how to enable static website hosting by using the Azure portal, the Azure CLI, or PowerShell.

有关分步教程,请参阅教程:在 Blob 存储中承载静态网站For a step-by-step tutorial, see Tutorial: Host a static website on Blob Storage.

启用静态网站宿主后,可以通过浏览器使用网站的公共 URL 查看网站的页面。After you enable static website hosting, you can view the pages of your site from a browser by using the public URL of the website.

使用 Azure 门户查找网站 URLFind the website URL by using the Azure portal

在存储帐户的 "帐户概述" 页旁显示的窗格中,选择 "静态网站"。In the pane that appears beside the account overview page of your storage account, select Static Website. 站点的 URL 将显示在 "主终结点" 字段中。The URL of your site appears in the Primary endpoint field.

Azure 存储静态网站指标 - 指标

在静态网站页面上启用指标Enable metrics on static website pages

一旦启用了指标,就会在 "指标" 仪表板中报告 $web容器中的文件的流量统计信息。Once you've enabled metrics, traffic statistics on files in the $web container are reported in the metrics dashboard.

  1. 单击 "设置" > 监视 > 指标"。Click on Settings > Monitoring > Metrics.

    将通过挂接到不同的指标 API 来生成指标数据。Metrics data are generated by hooking into different metrics APIs. 门户只会显示在给定时间范围内使用的 API 成员,以便重点关注可返回数据的成员。The portal only displays API members used within a given time frame in order to only focus on members that return data. 为了确保能够选择必要的 API 成员,第一步是扩展时间范围。In order to ensure you're able to select the necessary API member, the first step is to expand the time frame.

  2. 单击 "时间范围" 按钮,然后选择 "最近24小时",并单击 "应用"。Click on the time frame button and select Last 24 hours and then click Apply.

    Azure 存储静态网站指标 - 时间范围

  3. 从 "命名空间" 下拉选择 " Blob "。Select Blob from the Namespace drop down.

    Azure 存储静态网站指标 - 命名空间

  4. 然后选择“传出”指标。Then select the Egress metric.

    Azure 存储静态网站指标 - 指标

  5. 从“聚合”选择器中选择“总和”。Select Sum from the Aggregation selector.

    Azure 存储静态网站指标 - 聚合

  6. 单击 "添加筛选器" 按钮,并从属性选择器中选择 " API 名称"。Click the Add filter button and choose API name from the Property selector.

    Azure 存储静态网站指标 - API 名称

  7. 选中 "" 选择器中 " GetWebContent " 旁边的框,以填充指标报表。Check the box next to GetWebContent in the Values selector to populate the metrics report.

    Azure 存储静态网站指标 - GetWebContent

后续步骤Next steps