Azure 中站点到站点连接的日志

Azure 中站点到站点连接的日志

我需要帮助来诊断 Azure 和 Cisco ASA VPN 设备之间的站点到站点连接中的故障点。连接类型是基于策略的。我在 Azure 中哪里可以找到日志?

答案1

没有办法直接查看日志,但我们可以下载诊断日志VPN 网关的诊断日志。为了存储日志,您应该在 VPN 网关的同一资源组中添加存储帐户和存储容器。下面是一个使用 PowerShell 配置 VPN 网关诊断日志的示例(ARM):

# VNET Resource Group and Name
$rgName = ‘your resource name’
$vnetGwName = "your GW name"
$timestamp = get-date -uFormat "%d%m%y@%H%M%S"

# Details of existing Storage Account that will be used to collect the logs
$storageAccountName = "storage account name"
$storageAccountKey = ‘storage account key’
$captureDuration = 60
$storageContainer = "vpnlogs"
$logDownloadPath = "D:\vpnlogs (create the folder first)"
$Logfilename = "VPNDiagLog_" + $vnetGwName + "_" + $timestamp + ".txt"

# Set Storage Context and VNET Gateway ID
$storageContext = New-AzureStorageContext -StorageAccountName $storageAccountName -StorageAccountKey $storageAccountKey

# NOTE: This is an Azure Service Manager cmdlet and so no AzureRM on this one.  AzureRM will not work as we don’t get the gatewayID with it.
$vnetGws = Get-AzureVirtualNetworkGateway

# Added check for only provisioned gateways as older deleted gateways of same name can also appear in results and capture will fail
$vnetGwId = ($vnetGws | ? GatewayName -eq $vnetGwName | ? state -EQ "provisioned").GatewayID

# Start Azure VNET Gateway logging
Start-AzureVirtualNetworkGatewayDiagnostics  `
    -GatewayId $vnetGwId `
    -CaptureDurationInSeconds $captureDuration `
    -StorageContext $storageContext `
    -ContainerName $storageContainer

# Optional – Test VNET gateway connection to another server across the tunnel 
# Only use this if you are connected to the local network you are connecting to FROM Azure. Otherwise create some traffic across the link from on prem.
# Test-NetConnection -ComputerName 10.0.0.4 -CommonTCPPort RDP

# Wait for diagnostics capturing to complete
Sleep -Seconds $captureDuration

# Step 6 – Download VNET gateway diagnostics log
$logUrl = ( Get-AzureVirtualNetworkGatewayDiagnostics -GatewayId $vnetGwId).DiagnosticsUrl
$logContent = (Invoke-WebRequest -Uri $logUrl).RawContent
$logContent | Out-File -FilePath $logDownloadPath\$Logfilename

此脚本需要逐个执行。
有关诊断日志的更多信息,请参阅关联

相关内容