Applies to: ✔️ Front Door Premium
本文将指导你完成对 Azure Front Door Premium 层级的配置,以使用 Azure 专用链接服务私密连接到存储静态网站。
Prerequisites
- 拥有有效订阅的 Azure 帐户。 可以创建帐户。
- Create a Private Link service for your origin web server.
- 你的存储帐户上启用了存储静态网站。 了解如何启用静态网站。
启用与存储静态网站的专用链接
在本节中,你将专用链接服务映射到在 Azure Front Door 专用网络中创建的专用终结点。
Sign in to the Azure portal.
Within your Azure Front Door Premium profile, under Settings, select Origin groups.
选择包含要为其启用专用链接的存储静态网站原点的原点组。
选择“+ 添加原点”,以添加新的存储静态网站原点,或从该列表中选择以前创建的存储静态网站原点。
下表指示了在启用与 Azure Front Door 的专用链接时,在相应字段中要选择哪些值。 选择或输入以下设置,以配置你希望 Azure Front Door Premium 与之建立专用连接的存储静态网站。
Setting Value Name 输入一个名称来标识此存储静态网站原点。 Origin Type 存储(静态网站) Host name 从下拉列表中选择要用作源的主机。 源主机标头 您可以自定义源的主机头,也可以将其保留为默认值。 HTTP port 80 (default) HTTPS port 443 (default) Priority 不同的源可以具有不同的优先级,以分别提供主要、次要和备份源。 Weight 1000 (default). 当你想要分散流量时,请为不同的源分配权重。 Region 选择与源相同或最近的区域。 目标子资源 之前选定的且你的专用终结点可访问的资源的子资源类型。 You can select web or web_secondary. Request message 自定义批准专用终结点时显示的消息。 Then select Add to save your configuration. Then select Update to save your changes.
从存储帐户批准专用终结点连接
转到要以私密方式连接到 Azure Front Door Premium 的存储帐户。 Select Networking under Settings.
In Networking, select Private endpoint connections.
Select the pending private endpoint request from Azure Front Door Premium then select Approve.
Once approved, you can see the private endpoint connection status is Approved.
创建与 web_secondary 的专用终结点连接
When creating a private endpoint connection to the storage static website's secondary sub resource, you need to add a -secondary suffix to the origin host header. For example, if your origin host header is contoso.z13.web.core.chinacloudapi.cn, you need to change it to contoso-secondary.z13.web.core.chinacloudapi.cn.
添加原点并批准专用终结点连接后,可以测试与存储静态网站的专用链接连接。
本文将指导你完成对 Azure Front Door Premium 层级的配置,在 Azure CLI 中使用 Azure 专用链接服务以专用方式连接到存储帐户。
先决条件 - CLI
Prerequisites
可以使用本地 Azure CLI。
If you prefer, install the Azure CLI to run CLI reference commands.
本地 Azure CLI,请了解如何安装 Azure CLI。 如果在 Windows 或 macOS 上运行,请考虑在 Docker 容器中运行 Azure CLI。 有关详细信息,请参阅如何在 Docker 容器中运行 Azure CLI。
Sign in to the Azure CLI by using the az login command. 若要完成身份验证过程,请遵循终端中显示的步骤。 有关其他登录选项,请参阅使用 Azure CLI 登录。
出现提示时,请在首次使用时安装 Azure CLI 扩展。 有关扩展的详细信息,请参阅 将扩展与 Azure CLI 配合使用。
Run az version to find the version and dependent libraries that are installed. To upgrade to the latest version, run az upgrade.
- 拥有有效订阅的 Azure 帐户。 创建账户。
- 具有正常运行的 Azure Front Door Premium 配置文件、终结点和源组。 有关如何创建 Azure Front Door 配置文件的详细信息,请参阅创建 Front Door - CLI。
在 Azure Front Door Premium 中启用存储静态网站的专用链接
- 运行 az afd origin create 以创建新的 Azure Front Door 源。 输入以下设置,以配置你希望 Azure Front Door Premium 与之建立专用连接的存储静态网站。 Notice the
private-link-location
must be in one of the available regions and theprivate-link-sub-resource-type
must be web.
az afd origin create --enabled-state Enabled \
--resource-group testRG \
--origin-group-name default-origin-group \
--origin-name pvtStaticSite \
--profile-name testAFD \
--host-name example.z13.web.core.chinacloudapi.cn\
--origin-host-header example.z13.web.core.chinacloudapi.cn\
--http-port 80 \
--https-port 443 \
--priority 1 \
--weight 500 \
--enable-private-link true \
--private-link-location ChinaEast2 \
--private-link-request-message 'AFD Storage static website origin Private Link request.' \
--private-link-resource /subscriptions/00000000-0000-0000-0000-00000000000/resourceGroups/testRG/providers/Microsoft.Storage/storageAccounts/testingafdpl \
--private-link-sub-resource-type web
从存储帐户批准专用终结点连接
- 运行 az network private-endpoint-connection list,列出存储帐户的专用终结点连接。 查看输出第一行,记下存储帐户中可用的专用终结点连接的“资源 ID”。
az network private-endpoint-connection list -g testRG -n testingafdpl --type Microsoft.Storage/storageAccounts
- 运行 az network private-endpoint-connection approve cmdlet,批准专用终结点连接。
az network private-endpoint-connection approve --id /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testRG/providers/Microsoft.Storage/storageAccounts/testingafdpl/privateEndpointConnections/testingafdpl.00000000-0000-0000-0000-000000000000
创建与 Web_Secondary 的专用终结点连接
When creating a private endpoint connection to the storage static website's secondary sub-resource, you need to add a -secondary suffix to the origin host header. 例如,如果原始主机标头是 example.z13.web.core.chinacloudapi.cn
,则需要将其更改为 example-secondary.z13.web.core.chinacloudapi.cn
。
添加原点并批准专用终结点连接后,可以测试与存储静态网站的专用链接连接。
要避免的常见错误
配置启用了 Azure 专用链接的源时,常见错误如下:
- 将启用了 Azure 专用链接的源添加到包含公共源的现有源组。 Azure Front Door 不允许在同一源组中混合公共和专用源。
Next steps
了解有关专用链接服务与存储帐户的信息。