@@ -2800,3 +2800,149 @@ function Test-ApplicationGatewayWithListenerHostNames
2800
2800
Clean - ResourceGroup $rgname
2801
2801
}
2802
2802
}
2803
+
2804
+ function Test-ApplicationGatewayWithPrivateLinkConfiguration
2805
+ {
2806
+ param
2807
+ (
2808
+ $basedir = " ./"
2809
+ )
2810
+
2811
+ # Setup
2812
+ $location = Get-ProviderLocation " Microsoft.Network/applicationGateways" " westus2"
2813
+
2814
+ $rgname = Get-ResourceGroupName
2815
+ $appgwName = Get-ResourceName
2816
+ $vnetName = Get-ResourceName
2817
+ $gwSubnetName = Get-ResourceName
2818
+ $plsSubnetName = Get-ResourceName
2819
+ $publicIpName = Get-ResourceName
2820
+ $gipconfigname = Get-ResourceName
2821
+
2822
+ $frontendPort01Name = Get-ResourceName
2823
+ $fipconfigName = Get-ResourceName
2824
+ $listener01Name = Get-ResourceName
2825
+
2826
+ $poolName = Get-ResourceName
2827
+ $trustedRootCertName = Get-ResourceName
2828
+ $poolSetting01Name = Get-ResourceName
2829
+
2830
+ $rule01Name = Get-ResourceName
2831
+
2832
+ $probeHttpName = Get-ResourceName
2833
+
2834
+ $privateLinkIpConfigName1 = Get-ResourceName
2835
+ $privateLinkIpConfigName2 = Get-ResourceName
2836
+ $privateLinkIpConfigName3 = Get-ResourceName
2837
+
2838
+ $privateLinkConfigName = Get-ResourceName
2839
+ $privateLinkConfigName2 = Get-ResourceName
2840
+
2841
+ try
2842
+ {
2843
+ # Create the resource group
2844
+ $resourceGroup = New-AzResourceGroup - Name $rgname - Location $location - Tags @ { testtag = " APPGw tag" }
2845
+ # Create the Virtual Network
2846
+ $gwSubnet = New-AzVirtualNetworkSubnetConfig - Name $gwSubnetName - AddressPrefix 10.0 .0.0 / 24 - PrivateLinkServiceNetworkPoliciesFlag " Disabled"
2847
+ $plsSubnet = New-AzVirtualNetworkSubnetConfig - Name $plsSubnetName - AddressPrefix 10.0 .1.0 / 24 - PrivateLinkServiceNetworkPoliciesFlag " Disabled"
2848
+ $vnet = New-AzVirtualNetwork - Name $vnetName - ResourceGroupName $rgname - Location $location - AddressPrefix 10.0 .0.0 / 16 - Subnet $gwSubnet , $plsSubnet
2849
+ $vnet = Get-AzVirtualNetwork - Name $vnetName - ResourceGroupName $rgname
2850
+ $gwSubnet = Get-AzVirtualNetworkSubnetConfig - Name $gwSubnetName - VirtualNetwork $vnet
2851
+ $plsSubnet = Get-AzVirtualNetworkSubnetConfig - Name $plsSubnetName - VirtualNetwork $vnet
2852
+
2853
+ # Create public ip
2854
+ $publicip = New-AzPublicIpAddress - ResourceGroupName $rgname - name $publicIpName - location $location - AllocationMethod Static - sku Standard
2855
+
2856
+ # Create ip configuration
2857
+ $gipconfig = New-AzApplicationGatewayIPConfiguration - Name $gipconfigname - Subnet $gwSubnet
2858
+
2859
+ # private link configuration
2860
+ $privateLinkIpConfiguration1 = New-AzApplicationGatewayPrivateLinkIpConfiguration - Name $privateLinkIpConfigName1 - Subnet $plsSubnet - Primary
2861
+ $privateLinkIpConfiguration2 = New-AzApplicationGatewayPrivateLinkIpConfiguration - Name $privateLinkIpConfigName2 - Subnet $plsSubnet
2862
+ $privateLinkConfiguration = New-AzApplicationGatewayPrivateLinkConfiguration - Name $privateLinkConfigName - IpConfiguration $privateLinkIpConfiguration1 , $privateLinkIpConfiguration2
2863
+
2864
+ $fipconfig = New-AzApplicationGatewayFrontendIPConfig - Name $fipconfigName - PublicIPAddress $publicip - PrivateLinkConfiguration $privateLinkConfiguration
2865
+ $fp01 = New-AzApplicationGatewayFrontendPort - Name $frontendPort01Name - Port 80
2866
+ $listener01 = New-AzApplicationGatewayHttpListener - Name $listener01Name - Protocol Http - FrontendIPConfiguration $fipconfig - FrontendPort $fp01
2867
+
2868
+ # backend part
2869
+ # trusted root cert part
2870
+ $certFilePath = $basedir + " /ScenarioTests/Data/ApplicationGatewayAuthCert.cer"
2871
+ $trustedRoot01 = New-AzApplicationGatewayTrustedRootCertificate - Name $trustedRootCertName - CertificateFile $certFilePath
2872
+ $pool = New-AzApplicationGatewayBackendAddressPool - Name $poolName - BackendIPAddresses www.microsoft.com , www.bing.com
2873
+ $probeHttp = New-AzApplicationGatewayProbeConfig - Name $probeHttpName - Protocol Https - HostName " probe.com" - Path " /path/path.htm" - Interval 89 - Timeout 88 - UnhealthyThreshold 8 - port 1234
2874
+ $poolSetting01 = New-AzApplicationGatewayBackendHttpSetting - Name $poolSetting01Name - Port 443 - Protocol Https - Probe $probeHttp - CookieBasedAffinity Enabled - PickHostNameFromBackendAddress - TrustedRootCertificate $trustedRoot01
2875
+
2876
+ # rule
2877
+ $rule01 = New-AzApplicationGatewayRequestRoutingRule - Name $rule01Name - RuleType basic - BackendHttpSettings $poolSetting01 - HttpListener $listener01 - BackendAddressPool $pool
2878
+
2879
+ # sku
2880
+ $sku = New-AzApplicationGatewaySku - Name Standard_v2 - Tier Standard_v2
2881
+
2882
+ # autoscale configuration
2883
+ $autoscaleConfig = New-AzApplicationGatewayAutoscaleConfiguration - MinCapacity 3
2884
+
2885
+ # Create Application Gateway
2886
+ $appgw = New-AzApplicationGateway - Name $appgwName - ResourceGroupName $rgname - Zone 1 , 2 - Location $location - Probes $probeHttp - BackendAddressPools $pool - BackendHttpSettingsCollection $poolSetting01 - FrontendIpConfigurations $fipconfig - GatewayIpConfigurations $gipconfig - FrontendPorts $fp01 - HttpListeners $listener01 - RequestRoutingRules $rule01 - Sku $sku - TrustedRootCertificate $trustedRoot01 - AutoscaleConfiguration $autoscaleConfig - PrivateLinkConfiguration $privateLinkConfiguration
2887
+
2888
+ # Get Application Gateway
2889
+ $getgw = Get-AzApplicationGateway - Name $appgwName - ResourceGroupName $rgname
2890
+
2891
+ # Operational State
2892
+ Assert-AreEqual " Running" $getgw.OperationalState
2893
+
2894
+ # Verify PrivateLink Configuration
2895
+ Assert-NotNull $getgw.PrivateLinkConfigurations
2896
+ Assert-AreEqual 1 $getgw.PrivateLinkConfigurations.Count
2897
+ $getPrivateLinkConfig = Get-AzApplicationGatewayPrivateLinkConfiguration - Name $privateLinkConfigName - ApplicationGateway $getgw
2898
+ Assert-NotNull $getPrivateLinkConfig
2899
+ Assert-AreEqual $getPrivateLinkConfig.IpConfigurations.Count 2
2900
+
2901
+ # Verify Frontend Ip has PrivateLink Configuration
2902
+ $getFipConfig = Get-AzApplicationGatewayFrontendIPConfig - ApplicationGateway $getgw - Name $fipconfigName
2903
+ Assert-NotNull $getFipconfig
2904
+ Assert-NotNull $getFipconfig.PrivateLinkConfiguration
2905
+ Assert-AreEqual $getPrivateLinkConfig.Id $getFipconfig.PrivateLinkConfiguration.Id
2906
+
2907
+ # check autoscale configuration
2908
+ $autoscaleConfig01 = Get-AzApplicationGatewayAutoscaleConfiguration - ApplicationGateway $getgw
2909
+ Assert-NotNull $autoscaleConfig01
2910
+ Assert-AreEqual $autoscaleConfig01.MinCapacity 3
2911
+
2912
+ # Set AppGw
2913
+ $getgw01 = Set-AzApplicationGateway - ApplicationGateway $getgw
2914
+
2915
+ # Cannot add same PrivateLinkConfiguration
2916
+ Assert-ThrowsLike { Add-AzApplicationGatewayPrivateLinkConfiguration - ApplicationGateway $getgw01 - Name $privateLinkConfigName - IpConfiguration $privateLinkIpConfiguration1 } " *already exists*"
2917
+
2918
+ # add another private link configuration and change the ip configuration
2919
+ $getgw01 = Add-AzApplicationGatewayPrivateLinkConfiguration - ApplicationGateway $getgw01 - Name $privateLinkConfigName2 - IpConfiguration $privateLinkIpConfiguration1
2920
+ $privateLinkIpConfiguration3 = New-AzApplicationGatewayPrivateLinkIpConfiguration - Name $privateLinkIpConfigName3 - Subnet $plsSubnet - Primary
2921
+ $getgw01 = Set-AzApplicationGatewayPrivateLinkConfiguration - ApplicationGateway $getgw01 - Name $privateLinkConfigName2 - IpConfiguration $privateLinkIpConfiguration3
2922
+ $getPrivateLinkConfig = Get-AzApplicationGatewayPrivateLinkConfiguration - Name $privateLinkConfigName2 - ApplicationGateway $getgw01
2923
+ Assert-NotNull $getPrivateLinkConfig
2924
+ Assert-AreEqual $getPrivateLinkConfig.IpConfigurations.Count 1
2925
+ Assert-AreEqual $getPrivateLinkConfig.IpConfigurations.Name $privateLinkIpConfigName3
2926
+
2927
+ # add / remove privateLinkConfiguration
2928
+ $getgw = Set-AzApplicationGateway - ApplicationGateway $getgw01
2929
+ $privateLinkConfigurations = Get-AzApplicationGatewayPrivateLinkConfiguration - ApplicationGateway $getgw
2930
+ Assert-NotNull $privateLinkConfigurations
2931
+ Assert-AreEqual $privateLinkConfigurations.Count 2
2932
+
2933
+ $getgw01 = Remove-AzApplicationGatewayPrivateLinkConfiguration - ApplicationGateway $getgw01 - Name $privateLinkConfigName2
2934
+ $getgw = Set-AzApplicationGateway - ApplicationGateway $getgw01
2935
+
2936
+ $privateLinkConfigurations = Get-AzApplicationGatewayPrivateLinkConfiguration - ApplicationGateway $getgw
2937
+ Assert-NotNull $privateLinkConfigurations
2938
+ Assert-AreEqual $privateLinkConfigurations.Count 1
2939
+
2940
+ # Delete Application Gateway
2941
+ Remove-AzApplicationGateway - Name $appgwName - ResourceGroupName $rgname - Force
2942
+ }
2943
+ finally
2944
+ {
2945
+ # Cleanup
2946
+ Clean - ResourceGroup $rgname
2947
+ }
2948
+ }
0 commit comments