我需要找到一种方法来检索点到站点 VPN(类型:OpenVPN)的当前分配的 IP。
我将 C# 与 Azure 管理 nuget 包一起使用。
对于上下文,只有一种设备连接到点到站点,有时,我需要与他们联系以向他们发送命令。
谢谢。
编辑:
根据 Nancy Xiong 的回复,我想出了以下代码:
var restClient = RestClient
.Configure()
.WithEnvironment(AzureEnvironment.AzureGlobalCloud)
.WithCredentials(creds)
.Build();
var networkClient = new NetworkManagementClient(restClient);
networkClient.SubscriptionId = subscriptionId;
try
{
var connectionHealth =
await networkClient.P2sVpnGateways.GetP2sVpnConnectionHealthAsync(resourceGroup,vnetGatewayName);
var ipAddresses = connectionHealth.VpnClientConnectionHealth.AllocatedIpAddresses;
}
catch (Exception e)
{
Console.WriteLine(e);
throw;
}
但是,我得到以下异常:
Microsoft.Rest.Azure.CloudException: The resource type could not be found in the namespace 'Microsoft.Network' for api version '2019-06-01'.
任何想法?