对 VPN 虚拟网络网关和使用 Azure CLI 进行的连接进行故障排除

本文介绍如何使用网络观察程序 VPN 故障排除功能来诊断和排查 VPN 虚拟网络网关及其连接问题,以解决虚拟网络与本地网络之间的连接问题。 VPN 故障排除请求是长时间运行的请求,可能需要几分钟才返回结果。 故障排除日志存储在指定的存储帐户上的容器中。

先决条件

使用现有的存储帐户排除故障

本部分介绍如何使用现有的存储帐户对 VPN 虚拟网络网关或 VPN 连接进行故障排除。

使用 az storage account show 检索存储帐户的资源 ID。 然后使用 az network watcher troubleshooting start 开始排查 VPN 网关问题。

# Place the storage account ID into a variable.
storageId=$(az storage account show --name 'mystorageaccount' --resource-group 'myResourceGroup' --query 'id' --output tsv)

# Start VPN troubleshoot session.
az network watcher troubleshooting start --resource-group 'myResourceGroup' --resource 'myGateway' --resource-type 'vnetGateway' --storage-account $storageId --storage-path 'https://mystorageaccount.blob.core.chinacloudapi.cn/{containerName}'

故障排除请求完成后,将返回正常不正常并带有操作文本,提供有关如何解决问题的一般指导。 如果可以对问题采取措施,将提供一个包含更多指导的链接。

此外,详细的日志存储在你在上一命令中指定的存储帐户容器中。 有关详细信息,请参阅日志文件。 可以使用存储资源管理器或你首选的任何其他方式来访问和下载日志。 有关详细信息,请参阅存储资源管理器入门

使用新的存储帐户排除故障

本部分介绍如何使用新的存储帐户对 VPN 虚拟网络网关或 VPN 连接进行故障排除。

使用 az storage account createaz storage container create 分别创建新的存储帐户和容器。 然后使用 az network watcher troubleshooting start 开始排查 VPN 网关问题。

# Create a new storage account.
az storage account create --name 'mystorageaccount' --resource-group 'myResourceGroup' --location 'chinaeast' --sku 'Standard_LRS'

# Get the storage account keys.
az storage account keys list --resource-group 'myResourceGroup' --account-name 'mystorageaccount'

# Create a container.
az storage container create --account-name 'mystorageaccount' --account-key {storageAccountKey} --name 'vpn'

# Start VPN troubleshoot session.
az network watcher troubleshooting start --resource-group 'myResourceGroup' --resource 'myGateway' --resource-type 'vnetGateway' --storage-account 'mystorageaccount' --storage-path 'https://mystorageaccount.blob.core.chinacloudapi.cn/vpn'

故障排除请求完成后,将返回正常不正常并带有操作文本,提供有关如何解决问题的一般指导。 如果可以对问题采取措施,将提供一个包含更多指导的链接。

此外,详细的日志存储在你在上一命令中指定的存储帐户容器中。 有关详细信息,请参阅日志文件。 可以使用存储资源管理器或你首选的任何其他方式来访问和下载日志。 有关详细信息,请参阅存储资源管理器入门