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

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

先决条件

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

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

使用 Start-AzNetworkWatcherResourceTroubleshooting 开始排查 VPN 网关问题。

# Place the virtual network gateway configuration into a variable.
$vng = Get-AzVirtualNetworkGateway -Name 'myGateway' -ResourceGroupName 'myResourceGroup' 

# Place the storage account configuration into a variable.
$sa = Get-AzStorageAccount -ResourceGroupName 'myResourceGroup' -Name 'mystorageaccount'

# Start VPN troubleshoot session.
Start-AzNetworkWatcherResourceTroubleshooting -Location 'chinaeast' -TargetResourceId $vng.Id -StorageId $sa.Id -StoragePath 'https://mystorageaccount.blob.core.chinacloudapi.cn/{containerName}'

故障排除请求完成后,将返回 healthy 或 unhealthy。 详细的日志存储在你在上一命令中指定的存储帐户容器中。 有关详细信息,请参阅日志文件。 可以使用存储资源管理器或你首选的任何其他方式来访问和下载日志。 有关详细信息,请参阅存储资源管理器入门

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

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

使用 New-AzStorageAccountNew-AzStorageContainer 创建新的存储帐户和容器。 然后,使用 Start-AzNetworkWatcherResourceTroubleshooting 开始排查 VPN 网关问题。

# Place the virtual network gateway configuration into a variable.
$vng = Get-AzVirtualNetworkGateway -Name 'myGateway' -ResourceGroupName 'myResourceGroup' 

# Create a new storage account.
$sa = New-AzStorageAccount -Name 'mystorageaccount' -SKU 'Standard_LRS' -ResourceGroupName 'myResourceGroup' -Location 'chinaeast'

# Create a container.
Set-AzCurrentStorageAccount -ResourceGroupName $sa.ResourceGroupName -Name $sa.StorageAccountName
$sc = New-AzStorageContainer -Name 'vpn'

# Start VPN troubleshoot session.
Start-AzNetworkWatcherResourceTroubleshooting -Location 'chinaeast' -TargetResourceId $vng.Id -StorageId $sa.Id -StoragePath 'https://mystorageaccount.blob.core.chinacloudapi.cn/vpn'

故障排除请求完成后,将返回 healthy 或 unhealthy。 详细的日志存储在你在上一命令中指定的存储帐户容器中。 有关详细信息,请参阅日志文件。 可以使用存储资源管理器或你首选的任何其他方式来访问和下载日志。 有关详细信息,请参阅存储资源管理器入门