1
+ # ----------------------------------------------------------------------------------
2
+ #
3
+ # Copyright Microsoft Corporation
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ # Unless required by applicable law or agreed to in writing, software
9
+ # distributed under the License is distributed on an "AS IS" BASIS,
10
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ # See the License for the specific language governing permissions and
12
+ # limitations under the License.
13
+ # ----------------------------------------------------------------------------------
14
+
15
+ <#
16
+ . SYNOPSIS
17
+ Full Front Door CRUD cycle
18
+ #>
19
+ function Test-FrontDoorCrud
20
+ {
21
+ $Name = getAssetName
22
+ $resourceGroup = TestSetup- CreateResourceGroup
23
+ $resourceGroupName = $resourceGroup.ResourceGroupName
24
+ $tags = @ {" tag1" = " value1" ; " tag2" = " value2" }
25
+ $hostName = " $Name .azurefd.net"
26
+ $routingrule1 = New-AzureRmFrontDoorRoutingRuleObject - Name " routingrule1" - FrontDoorName $Name - ResourceGroupName $resourceGroupName - FrontendEndpointName " frontendEndpoint1" - BackendPoolName " backendPool1"
27
+ $backend1 = New-AzureRmFrontDoorBackendObject - Address " contoso1.azurewebsites.net"
28
+ $healthProbeSetting1 = New-AzureRmFrontDoorHealthProbeSettingObject - Name " healthProbeSetting1"
29
+ $loadBalancingSetting1 = New-AzureRmFrontDoorLoadBalancingSettingObject - Name " loadbalancingsetting1"
30
+ $frontendEndpoint1 = New-AzureRmFrontDoorFrontendEndpointObject - Name " frontendendpoint1" - HostName $hostName
31
+ $backendpool1 = New-AzureRmFrontDoorBackendPoolObject - Name " backendpool1" - FrontDoorName $Name - ResourceGroupName $resourceGroupName - Backend $backend1 - HealthProbeSettingsName " healthProbeSetting1" - LoadBalancingSettingsName " loadBalancingSetting1"
32
+ New-AzureRmFrontDoor - Name $Name - ResourceGroupName $resourceGroupName - RoutingRule $routingrule1 - BackendPool $backendpool1 - FrontendEndpoint $frontendEndpoint1 - LoadBalancingSetting $loadBalancingSetting1 - HealthProbeSetting $healthProbeSetting1 - Tag $tags
33
+
34
+ $retrievedFrontDoor = Get-AzureRmFrontDoor - Name $Name - ResourceGroupName $resourceGroupName
35
+ Assert-NotNull $retrievedFrontDoor
36
+ Assert-AreEqual $Name $retrievedFrontDoor.Name
37
+ Assert-AreEqual $routingrule1.Name $retrievedFrontDoor.RoutingRules [0 ].Name
38
+ Assert-AreEqual $loadBalancingSetting1.Name $retrievedFrontDoor.LoadBalancingSettings [0 ].Name
39
+ Assert-AreEqual $healthProbeSetting1.Name $retrievedFrontDoor.HealthProbeSettings [0 ].Name
40
+ Assert-AreEqual $backendpool1.Name $retrievedFrontDoor.BackendPools [0 ].Name
41
+ Assert-AreEqual $frontendEndpoint1.Name $retrievedFrontDoor.FrontendEndpoints [0 ].Name
42
+ Assert-Tags $tags $retrievedFrontDoor.Tags
43
+
44
+ $newTags = @ {" tag1" = " value3" ; " tag2" = " value4" }
45
+ $updatedFrontDoor = Set-AzureRmFrontDoor - Name $Name - ResourceGroupName $resourceGroupName - Tag $newTags
46
+ Assert-NotNull $updatedFrontDoor
47
+ Assert-AreEqual $Name $updatedFrontDoor.Name
48
+ Assert-AreEqual $routingrule1.Name $updatedFrontDoor.RoutingRules [0 ].Name
49
+ Assert-AreEqual $loadBalancingSetting1.Name $updatedFrontDoor.LoadBalancingSettings [0 ].Name
50
+ Assert-AreEqual $healthProbeSetting1.Name $updatedFrontDoor.HealthProbeSettings [0 ].Name
51
+ Assert-AreEqual $backendpool1.Name $updatedFrontDoor.BackendPools [0 ].Name
52
+ Assert-AreEqual $frontendEndpoint1.Name $updatedFrontDoor.FrontendEndpoints [0 ].Name
53
+ Assert-Tags $newTags $updatedFrontDoor.Tags
54
+
55
+ $removed = Remove-AzureRmFrontDoor - Name $Name - ResourceGroupName $resourceGroupName - PassThru
56
+ Assert-True { $removed }
57
+ Assert-ThrowsContains { Get-AzureRmFrontDoor - Name $Name - ResourceGroupName $resourceGroupName } " does not exist"
58
+
59
+ Remove-AzureRmResourceGroup - Name $ResourceGroupName - Force
60
+ }
61
+
62
+ <#
63
+ . SYNOPSIS
64
+ Front Door cycle with piping
65
+ #>
66
+ function Test-FrontDoorCrudWithPiping
67
+ {
68
+ $Name = getAssetName
69
+ $resourceGroup = TestSetup- CreateResourceGroup
70
+ $resourceGroupName = $resourceGroup.ResourceGroupName
71
+ $tags = @ {" tag1" = " value1" ; " tag2" = " value2" }
72
+ $hostName = " $Name .azurefd.net"
73
+ $routingrule1 = New-AzureRmFrontDoorRoutingRuleObject - Name " routingrule1" - FrontDoorName $Name - ResourceGroupName $resourceGroupName - FrontendEndpointName " frontendEndpoint1" - BackendPoolName " backendPool1"
74
+ $backend1 = New-AzureRmFrontDoorBackendObject - Address " contoso1.azurewebsites.net"
75
+ $healthProbeSetting1 = New-AzureRmFrontDoorHealthProbeSettingObject - Name " healthProbeSetting1"
76
+ $loadBalancingSetting1 = New-AzureRmFrontDoorLoadBalancingSettingObject - Name " loadbalancingsetting1"
77
+ $frontendEndpoint1 = New-AzureRmFrontDoorFrontendEndpointObject - Name " frontendendpoint1" - HostName $hostName
78
+ $backendpool1 = New-AzureRmFrontDoorBackendPoolObject - Name " backendpool1" - FrontDoorName $Name - ResourceGroupName $resourceGroupName - Backend $backend1 - HealthProbeSettingsName " healthProbeSetting1" - LoadBalancingSettingsName " loadBalancingSetting1"
79
+ New-AzureRmFrontDoor - Name $Name - ResourceGroupName $resourceGroupName - RoutingRule $routingrule1 - BackendPool $backendpool1 - FrontendEndpoint $frontendEndpoint1 - LoadBalancingSetting $loadBalancingSetting1 - HealthProbeSetting $healthProbeSetting1 - Tag $tags
80
+
81
+ $newTags = @ {" tag1" = " value3" ; " tag2" = " value4" }
82
+ $updatedFrontDoor = Get-AzureRmFrontDoor - Name $Name - ResourceGroupName $resourceGroupName | Set-AzureRmFrontDoor - Tag $newTags
83
+ Assert-NotNull $updatedFrontDoor
84
+ Assert-AreEqual $Name $updatedFrontDoor.Name
85
+ Assert-AreEqual $routingrule1.Name $updatedFrontDoor.RoutingRules [0 ].Name
86
+ Assert-AreEqual $loadBalancingSetting1.Name $updatedFrontDoor.LoadBalancingSettings [0 ].Name
87
+ Assert-AreEqual $healthProbeSetting1.Name $updatedFrontDoor.HealthProbeSettings [0 ].Name
88
+ Assert-AreEqual $backendpool1.Name $updatedFrontDoor.BackendPools [0 ].Name
89
+ Assert-AreEqual $frontendEndpoint1.Name $updatedFrontDoor.FrontendEndpoints [0 ].Name
90
+ Assert-Tags $newTags $updatedFrontDoor.Tags
91
+
92
+ $removed = Get-AzureRmFrontDoor - Name $Name - ResourceGroupName $resourceGroupName | Remove-AzureRmFrontDoor - PassThru
93
+ Assert-True { $removed }
94
+ Assert-ThrowsContains { Get-AzureRmFrontDoor - Name $Name - ResourceGroupName $resourceGroupName } " does not exist"
95
+ }
0 commit comments