@@ -644,12 +644,12 @@ function Test-ApplicationGatewayCRUDRewriteRuleSet
644
644
# Get Application Gateway
645
645
$getgw = Get-AzApplicationGateway - Name $appgwName - ResourceGroupName $rgname
646
646
647
- $rewriteRuleSet = Get-AzureRmApplicationGatewayRewriteRuleSet - Name $rewriteRuleSetName - ApplicationGateway $getgw
647
+ $rewriteRuleSet = Get-AzApplicationGatewayRewriteRuleSet - Name $rewriteRuleSetName - ApplicationGateway $getgw
648
648
Assert-NotNull $rewriteRuleSet
649
649
Assert-AreEqual $rewriteRuleSet.RewriteRules.Count 1
650
650
Assert-NotNull $rewriteRuleSet.RewriteRules [0 ].ActionSet
651
651
652
- $rewriteRuleSet = Get-AzureRmApplicationGatewayRewriteRuleSet - ApplicationGateway $getgw
652
+ $rewriteRuleSet = Get-AzApplicationGatewayRewriteRuleSet - ApplicationGateway $getgw
653
653
Assert-NotNull $rewriteRuleSet
654
654
Assert-AreEqual $rewriteRuleSet.Count 1
655
655
@@ -685,8 +685,8 @@ function Test-ApplicationGatewayCRUDRewriteRuleSet
685
685
Assert-NotNull $autoscaleConfig01
686
686
Assert-AreEqual $autoscaleConfig01.MinCapacity 3
687
687
688
- Set-AzureRmApplicationGatewayAutoscaleConfiguration - ApplicationGateway $getgw - MinCapacity 3 - MaxCapacity 10
689
- $autoscaleConfig02 = Get-AzureRmApplicationGatewayAutoscaleConfiguration - ApplicationGateway $getgw
688
+ Set-AzApplicationGatewayAutoscaleConfiguration - ApplicationGateway $getgw - MinCapacity 3 - MaxCapacity 10
689
+ $autoscaleConfig02 = Get-AzApplicationGatewayAutoscaleConfiguration - ApplicationGateway $getgw
690
690
Assert-NotNull $autoscaleConfig02
691
691
Assert-AreEqual $autoscaleConfig02.MinCapacity 3
692
692
Assert-AreEqual $autoscaleConfig02.MaxCapacity 10
@@ -701,29 +701,29 @@ function Test-ApplicationGatewayCRUDRewriteRuleSet
701
701
$getgw01 = Set-AzApplicationGateway - ApplicationGateway $getgw
702
702
703
703
# Rewrite Rule Set
704
- Assert-ThrowsLike { Add-AzureRmApplicationGatewayRewriteRuleSet - ApplicationGateway $getgw01 - Name $rewriteRuleSetName - RewriteRule $rewriteRule } " *already exists*"
705
- $rewriteRuleSet = Add-AzureRmApplicationGatewayRewriteRuleSet - ApplicationGateway $getgw01 - Name $rewriteRuleSetName2 - RewriteRule $rewriteRule
706
- $getgw = Set-AzureRmApplicationGateway - ApplicationGateway $getgw01
704
+ Assert-ThrowsLike { Add-AzApplicationGatewayRewriteRuleSet - ApplicationGateway $getgw01 - Name $rewriteRuleSetName - RewriteRule $rewriteRule } " *already exists*"
705
+ $rewriteRuleSet = Add-AzApplicationGatewayRewriteRuleSet - ApplicationGateway $getgw01 - Name $rewriteRuleSetName2 - RewriteRule $rewriteRule
706
+ $getgw = Set-AzApplicationGateway - ApplicationGateway $getgw01
707
707
708
- $rewriteRuleSet = Get-AzureRmApplicationGatewayRewriteRuleSet - ApplicationGateway $getgw
708
+ $rewriteRuleSet = Get-AzApplicationGatewayRewriteRuleSet - ApplicationGateway $getgw
709
709
Assert-NotNull $rewriteRuleSet
710
710
Assert-AreEqual $rewriteRuleSet.Count 2
711
711
712
- $rewriteRuleSet = Remove-AzureRmApplicationGatewayRewriteRuleSet - ApplicationGateway $getgw01 - Name $rewriteRuleSetName2
713
- $getgw = Set-AzureRmApplicationGateway - ApplicationGateway $getgw01
712
+ $rewriteRuleSet = Remove-AzApplicationGatewayRewriteRuleSet - ApplicationGateway $getgw01 - Name $rewriteRuleSetName2
713
+ $getgw = Set-AzApplicationGateway - ApplicationGateway $getgw01
714
714
715
- $rewriteRuleSet = Get-AzureRmApplicationGatewayRewriteRuleSet - ApplicationGateway $getgw
715
+ $rewriteRuleSet = Get-AzApplicationGatewayRewriteRuleSet - ApplicationGateway $getgw
716
716
Assert-NotNull $rewriteRuleSet
717
717
Assert-AreEqual $rewriteRuleSet.Count 1
718
718
719
- $headerConfiguration = New-AzureRmApplicationGatewayRewriteRuleHeaderConfiguration - HeaderName " ghi" - HeaderValue " jkl"
720
- $actionSet = New-AzureRmApplicationGatewayRewriteRuleActionSet - RequestHeaderConfiguration $headerConfiguration
721
- $rewriteRule2 = New-AzureRmApplicationGatewayRewriteRule - Name $rewriteRuleName - ActionSet $actionSet
719
+ $headerConfiguration = New-AzApplicationGatewayRewriteRuleHeaderConfiguration - HeaderName " ghi" - HeaderValue " jkl"
720
+ $actionSet = New-AzApplicationGatewayRewriteRuleActionSet - RequestHeaderConfiguration $headerConfiguration
721
+ $rewriteRule2 = New-AzApplicationGatewayRewriteRule - Name $rewriteRuleName - ActionSet $actionSet
722
722
723
- Assert-ThrowsLike { Set-AzureRmApplicationGatewayRewriteRuleSet - ApplicationGateway $getgw - Name " fakeName" - RewriteRule $rewriteRule2 } " *does not exist*"
724
- $rewriteRuleSet = Set-AzureRmApplicationGatewayRewriteRuleSet - ApplicationGateway $getgw - Name $rewriteRuleSetName - RewriteRule $rewriteRule2
725
- $getgw = Set-AzureRmApplicationGateway - ApplicationGateway $getgw01
726
- $rewriteRuleSet = Get-AzureRmApplicationGatewayRewriteRuleSet - ApplicationGateway $getgw - Name $rewriteRuleSetName
723
+ Assert-ThrowsLike { Set-AzApplicationGatewayRewriteRuleSet - ApplicationGateway $getgw - Name " fakeName" - RewriteRule $rewriteRule2 } " *does not exist*"
724
+ $rewriteRuleSet = Set-AzApplicationGatewayRewriteRuleSet - ApplicationGateway $getgw - Name $rewriteRuleSetName - RewriteRule $rewriteRule2
725
+ $getgw = Set-AzApplicationGateway - ApplicationGateway $getgw01
726
+ $rewriteRuleSet = Get-AzApplicationGatewayRewriteRuleSet - ApplicationGateway $getgw - Name $rewriteRuleSetName
727
727
Assert-AreEqual $rewriteRuleSet.RewriteRules [0 ].Name $rewriteRule2.Name
728
728
729
729
# check sku
@@ -764,6 +764,7 @@ function Test-ApplicationGatewayCRUD3
764
764
765
765
$rgname = Get-ResourceGroupName
766
766
$appgwName = Get-ResourceName
767
+ $identityName = Get-ResourceName
767
768
$vnetName = Get-ResourceName
768
769
$gwSubnetName = Get-ResourceName
769
770
$publicIpName = Get-ResourceName
@@ -791,6 +792,9 @@ function Test-ApplicationGatewayCRUD3
791
792
$vnet = Get-AzvirtualNetwork - Name $vnetName - ResourceGroupName $rgname
792
793
$gwSubnet = Get-AzVirtualNetworkSubnetConfig - Name $gwSubnetName - VirtualNetwork $vnet
793
794
795
+ # Create Managed Identity
796
+ $identity = New-AzUserAssignedIdentity - Name $identityName - Location $location - ResourceGroup $rgname
797
+
794
798
# Create public ip
795
799
$publicip = New-AzPublicIpAddress - ResourceGroupName $rgname - name $publicIpName - location $location - AllocationMethod Static - sku Standard
796
800
@@ -821,8 +825,11 @@ function Test-ApplicationGatewayCRUD3
821
825
# security part
822
826
$sslPolicy = New-AzApplicationGatewaySslPolicy - PolicyType Custom - MinProtocolVersion TLSv1_1 - CipherSuite " TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256" , " TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384" , " TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA" , " TLS_RSA_WITH_AES_128_GCM_SHA256"
823
827
828
+ # appgw identity
829
+ $appgwIdentity = New-AzApplicationGatewayIdentity - UserAssignedIdentity $identity.Id
830
+
824
831
# Create Application Gateway
825
- $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 - SslPolicy $sslPolicy - TrustedRootCertificate $trustedRoot01 - AutoscaleConfiguration $autoscaleConfig
832
+ $appgw = New-AzApplicationGateway - Identity $appgwIdentity - 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 - SslPolicy $sslPolicy - TrustedRootCertificate $trustedRoot01 - AutoscaleConfiguration $autoscaleConfig
826
833
827
834
# Get Application Gateway
828
835
$getgw = Get-AzApplicationGateway - Name $appgwName - ResourceGroupName $rgname
@@ -852,7 +859,7 @@ function Test-ApplicationGatewayCRUD3
852
859
Assert-NotNull $autoscaleConfig01
853
860
Assert-AreEqual $autoscaleConfig01.MinCapacity 3
854
861
855
- # Next setup preparation
862
+ # Next: Manual sku gateway
856
863
857
864
# remove autoscale config
858
865
$getgw = Remove-AzApplicationGatewayAutoscaleConfiguration - ApplicationGateway $getgw - Force
@@ -868,6 +875,25 @@ function Test-ApplicationGatewayCRUD3
868
875
Assert-AreEqual $sku01.Name Standard_v2
869
876
Assert-AreEqual $sku01.Tier Standard_v2
870
877
878
+ # Next: Set Identity on an existing gateway without identity
879
+ # First, Removing identity from the gateway
880
+ Remove-AzApplicationGatewayIdentity - ApplicationGateway $getgw01
881
+
882
+ # Set Application Gateway
883
+ $getgw02 = Set-AzApplicationGateway - ApplicationGateway $getgw01
884
+ Assert-Null $ (Get-AzApplicationGatewayIdentity - ApplicationGateway $getgw01 )
885
+
886
+ # Set identity
887
+ Set-AzApplicationGatewayIdentity - ApplicationGateway $getgw02 - UserAssignedIdentityId $identity.Id
888
+
889
+ # Set Application Gateway
890
+ $getgw03 = Set-AzApplicationGateway - ApplicationGateway $getgw02
891
+ $identity01 = Get-AzApplicationGatewayIdentity - ApplicationGateway $getgw03
892
+ Assert-AreEqual $identity01.UserAssignedIdentities.Count 1
893
+ Assert-NotNull $identity01.UserAssignedIdentities.Values [0 ].PrincipalId
894
+ Assert-NotNull $identity01.UserAssignedIdentities.Values [0 ].ClientId
895
+
896
+
871
897
# Stop Application Gateway
872
898
$getgw1 = Stop-AzApplicationGateway - ApplicationGateway $getgw01
873
899
0 commit comments