你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

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

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

先决条件

  • 具有活动订阅的 Azure 帐户。 免费创建帐户

  • 在虚拟网络网关区域中启用的网络观察程序。 有关详细信息,请参阅启用或禁用 Azure 网络观察程序

  • 一个虚拟网络网关。 有关详细信息,请参阅支持的网关类型

  • Azure Cloud Shell 或 Azure CLI。

    本文中的步骤在 Azure Cloud Shell 中以交互方式运行 Azure CLI 命令。 要在 Cloud Shell 中运行命令,请选择代码块右上角的“打开 Cloud Shell”。 选择“复制”以复制代码,并将其粘贴到 Cloud Shell 以运行。 也可以从 Azure 门户中运行 Cloud Shell。

    还可以 在本地安装 Azure CLI 以运行命令。 如果在本地运行 Azure CLI,请使用 az login 命令登录到 Azure。

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

本部分介绍如何使用现有的存储帐户对 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.windows.net/{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 'eastus' --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.windows.net/vpn'

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

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