我从这里使用模板创建了一个 DTL - https://github.com/Azure/azure-devtestlab/blob/master/Samples/101-dtl-create-lab/azuredeploy.json
之后,我正在更改子网并使用以下脚本创建 P2S VPN -
$VNetName = "dtlinfratest2"
$RG = "infratest2"
$Location = "westeurope"
$MyP2SRootCertPubKeyBase64 = "XXXXXXX"
# each virtaul network is inside a dev test lab so below values can hold good for all cases.
# Note: This is going to fail if VM exists in the virtual network
$GWSubName = "GatewaySubnet"
$VNetPrefix1 = "10.0.0.0/16"
$SubPrefix = "10.0.0.0/24"
$GWSubPrefix = "10.0.200.0/26"
$VPNClientAddressPool = "132.16.201.0/24"
$GWName = "GateWay"
$GWIPName = "GateWayIP"
$GWIPconfName = "GateWayIPConfig"
$vnet = Get-AzureRmVirtualNetwork -Name $VNetName -ResourceGroupName $RG
$fesub = New-AzureRmVirtualNetworkSubnetConfig -Name $vnet.Subnets.name -AddressPrefix $SubPrefix
$gwsub = New-AzureRmVirtualNetworkSubnetConfig -Name $GWSubName -AddressPrefix $GWSubPrefix
$vn = New-AzureRmVirtualNetwork -Name $VNetName -ResourceGroupName $RG -Location $Location -AddressPrefix $VNetPrefix1 -Subnet $fesub, $gwsub -Force
$subnet = Get-AzureRmVirtualNetworkSubnetConfig -Name $GWSubName -VirtualNetwork $vn
$pip = New-AzureRmPublicIpAddress -Name $GWIPName -ResourceGroupName $RG -Location $Location -AllocationMethod Dynamic
$ipconf = New-AzureRmVirtualNetworkGatewayIpConfig -Name $GWIPconfName -Subnet $subnet -PublicIpAddress $pip
$p2srootcert = New-AzureRmVpnClientRootCertificate -Name "P2SVNETRootCertName" -PublicCertData $MyP2SRootCertPubKeyBase64
New-AzureRmVirtualNetworkGateway -Name $GWName -ResourceGroupName $RG -Location $Location -IpConfigurations $ipconf -GatewayType Vpn -VpnType RouteBased -EnableBgp $false -GatewaySku Standard -VpnClientAddressPool $VPNClientAddressPool -VpnClientRootCertificates $p2srootcert
我正在创建子网中没有任何问题的虚拟机,并且在预定义的时间后虚拟机到期,之后我观察到虚拟机创建在实验室内失败。错误信息-
子网 DtlInfraTest2子网未启用或不是指定虚拟网络的一部分 /subscriptions/XXXXX/resourcegroups/infratest2/providers/microsoft.devtestlab/labs/infratest2/virtualnetworks/dtlinfratest2
我检查了实验室内的网络选项卡,发现“在虚拟机创建中使用”已关闭,除非我手动勾选绿色,否则我无法创建 VM。
我尝试搜索 powershell 命令,但找不到。默认情况下,当我们使用模板创建虚拟机时,“在虚拟机创建中使用”,但当所有虚拟机自动过期时会关闭