From 1d366f2c00254a7b4cdbf1e7d7a9d1039f527e9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sr=C4=91an=20Bo=C5=BEovi=C4=87?= Date: Fri, 24 Aug 2018 03:56:01 +0200 Subject: [PATCH] fix --- .../attach-vpn-gateway/attachVPNGateway.ps1 | 19 +++++++++++++++ .../attach-vpn-gateway/azuredeploy.json | 24 +------------------ 2 files changed, 20 insertions(+), 23 deletions(-) diff --git a/samples/manage/azure-sql-db-managed-instance/attach-vpn-gateway/attachVPNGateway.ps1 b/samples/manage/azure-sql-db-managed-instance/attach-vpn-gateway/attachVPNGateway.ps1 index cc24262a..c0cd07bc 100644 --- a/samples/manage/azure-sql-db-managed-instance/attach-vpn-gateway/attachVPNGateway.ps1 +++ b/samples/manage/azure-sql-db-managed-instance/attach-vpn-gateway/attachVPNGateway.ps1 @@ -81,6 +81,22 @@ function Load-ResourceGroup { } } +function Set-VirtualNetwork +{ + param($virtualNetwork) + + Write-Host "Applying changes to the virtual network." + Try + { + Set-AzureRmVirtualNetwork -VirtualNetwork $virtualNetwork -ErrorAction Stop | Out-Null + } + Catch + { + Write-Host "Failed: $_" -ForegroundColor Red + } + +} + function ConvertCidrToUint32Array { param($cidrRange) @@ -166,6 +182,9 @@ $gatewaySubnetPrefix = CalculateNextAddressPrefix $virtualNetwork 28 $vpnClientAddressPoolPrefix = CalculateVpnClientAddressPoolPrefix $gatewaySubnetPrefix +$virtualNetwork.AddressSpace.AddressPrefixes.Add($gatewaySubnetPrefix) +Add-AzureRmVirtualNetworkSubnetConfig -Name GatewaySubnet -VirtualNetwork $virtualNetwork -AddressPrefix $gatewaySubnetPrefix | Out-Null + Write-Host # Start the deployment diff --git a/samples/manage/azure-sql-db-managed-instance/attach-vpn-gateway/azuredeploy.json b/samples/manage/azure-sql-db-managed-instance/attach-vpn-gateway/azuredeploy.json index 6a53bcec..7f357ff6 100644 --- a/samples/manage/azure-sql-db-managed-instance/attach-vpn-gateway/azuredeploy.json +++ b/samples/manage/azure-sql-db-managed-instance/attach-vpn-gateway/azuredeploy.json @@ -42,27 +42,6 @@ "clientRootCertName": "RootCert" }, "resources": [ - { - "name": "[parameters('virtualNetworkName')]", - "type": "Microsoft.Network/virtualNetworks", - "apiVersion": "2018-02-01", - "location": "[parameters('location')]", - "properties": { - "addressSpace": { - "addressPrefixes": [ - "[parameters('gatewaySubnetPrefix')]" - ] - }, - "subnets": [ - { - "name": "[variables('gatewaySubnetName')]", - "properties": { - "addressPrefix": "[parameters('gatewaySubnetPrefix')]" - } - } - ] - } - }, { "apiVersion": "2017-10-01", "type": "Microsoft.Network/publicIPAddresses", @@ -78,8 +57,7 @@ "name": "[variables('gatewayName')]", "location": "[resourceGroup().location]", "dependsOn": [ - "[concat('Microsoft.Network/publicIPAddresses/', variables('gatewayPublicIpAddressName'))]", - "[concat('Microsoft.Network/virtualNetworks/', parameters('virtualNetworkName'))]" + "[concat('Microsoft.Network/publicIPAddresses/', variables('gatewayPublicIpAddressName'))]" ], "properties": { "ipConfigurations": [