适用于:Azure 本地 2411.1 及更高版本
在 Azure 订阅中创建 Arc 网关资源后,就可以启用新的 Arc 网关预览功能。 本文详细介绍了如何在 Arc 注册前手动配置 Arc 代理。
重要
此功能目前处于预览状态。 有关适用于 Beta 版、预览版或尚未正式发布的 Azure 功能的法律条款,请参阅 适用于 Microsoft azure 预览版的补充使用条款 。
先决条件
在继续之前,请确保满足以下先决条件:
你有权访问运行版本 2411.1 或更高版本的 Azure Local 实例。 以前的版本不支持此方案。
在用于部署 Azure Local 的同一订阅中创建的 Arc 网关资源。 有关详细信息,请参阅 在 Azure 中创建 Arc 网关资源。
步骤 1:手动配置代理
如果需要在启动 Arc 注册过程之前在 Azure 本地计算机上配置 Arc 代理,请按照“ 为 Azure 本地配置代理设置”中的说明作。
确保为系统中的所有计算机配置了代理和旁路列表。
步骤 2:获取 ArcGatewayID
要在 Azure Local 计算机上运行注册脚本,需要从 Azure 获取代理和 Arc 网关 ID (ArcGatewayID)。 你可以在资源的 Azure 门户概述页上找到 Arc 网关 ID。
步骤 3:在 Azure Arc 中注册新计算机
要在 Azure Arc 中注册新的版本 2408 或版本 2411 计算机,可通过传送 ArcGatewayID 参数和代理服务器参数来运行初始化脚本。 下面举例说明如何更改初始化脚本中的 Invoke-AzStackHciArcInitialization
参数:
#Define the subscription where you want to register your server as Arc device.
$Subscription = "yoursubscription"
#Define the resource group where you want to register your server as Arc device.
$RG = "yourresourcegroupname"
#Define the tenant you will use to register your server as Arc device.
$Tenant = "yourtenant"
#Define Proxy Server if necessary
$ProxyServer = "http://x.x.x.x:port"
#Define the Arc gateway resource ID from Azure
$ArcgwId = "/subscriptions/yoursubscription/resourceGroups/yourresourcegroupname/providers/Microsoft.HybridCompute/gateways/yourarcgatewayname"
#Define the bypass list for the proxy. Use comma to separate each item from the list.
# Use "localhost" instead of <local>
# Use specific IPs such as 127.0.0.1 without mask
# Use * for subnets allowlisting. 192.168.1.* for /24 exclusions. Use 192.168.*.* for /16 exclusions.
# Append * for domain names exclusions like *.contoso.com
# DO NOT INCLUDE .svc on the list. The registration script takes care of Environment Variables configuration.
$ProxyBypassList = "localhost,127.0.0.1,*.contoso.com,machine1,machine2,machine3,machine4,machine5,192.168.*.*,AzureLocal-1"
#Connect to your Azure account and subscription
Connect-AzAccount -SubscriptionId $Subscription -TenantId $Tenant -DeviceCode
#Get the Access Token and Account ID for the registration
$ARMtoken = (Get-AzAccessToken).Token
#Get the Account ID for the registration
$id = (Get-AzContext).Account.Id
#Invoke the registration script with Proxy and ArcgatewayID
Invoke-AzStackHciArcInitialization -SubscriptionID $Subscription -ResourceGroup $RG -TenantID $Tenant -Region australiaeast -Cloud "AzureCloud" -ArmAccessToken $ARMtoken -AccountID $id -Proxy $ProxyServer -ProxyBypass $ProxyBypassList -ArcGatewayID $ArcgwId
步骤 4:启动 Azure Local 云部署
在 Azure Arc 中注册 Azure Local 计算机并安装所有扩展后,可以从 Azure 门户或使用以下文章中记录的 ARM 模板开始部署:
步骤 5:验证设置是否成功
部署验证启动后,你可以从系统连接到第一台 Azure Local 计算机,并打开 Arc 网关日志,以监控哪些终结点重定向到了 Arc 网关,以及哪些终结点在继续使用防火墙或代理。
可以在以下位置找到 Arc 网关日志: c:\programdata\AzureConnectedMAchineAgent\Log\arcproxy.log。
若要检查 Arc 代理配置并验证它是否正在使用 Arc 网关,请运行以下命令:c:\program files\AzureConnectedMachineAgent>.\azcmagent show
结果应显示以下值:
代理版本为 1.45 或更高版本。
代理状态是“已连接”。
当未使用 Arc 网关时,“使用 HTTPS 代理”为空。 启用 Arc 网关时,它应显示为
http://localhost:40343
。上游代理 显示企业代理服务器和端口。
当未使用 Arc 网关时,Azure Arc 代理显示为“已停止”;当已启用 Arc 网关时,则显示为“正在运行”。
没有 Arc 网关的 Arc 代理:
使用 Arc 网关的 Arc 代理:
此外,若要验证安装程序是否成功,你可以运行以下命令:c:\program files\AzureConnectedMachineAgent>.\azcmagent check
。
响应应指示 connection.type
设置为 gateway
,并且所有 URL 的“可访问”列应指示 true:
没有 Arc 网关的 Arc 代理:
启用 Arc 网关的 Arc 代理:
你还可以通过查看网关路由器日志来审核网关流量。
若要查看 Windows 上的网关路由器日志,请在 PowerShell 中运行 azcmagent logs
命令。 在生成的 .zip 文件中,日志位于 C:\ProgramData\Microsoft\ArcGatewayRouter 文件夹中。
后续步骤
此功能仅在 Azure Local 2411.1 或更高版本中可用。