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
+ Tests ExpressRouteCircuitCRUD.
18
+ #>
19
+ function Test-ExpressRouteCircuitCRUD
20
+ {
21
+ # Setup
22
+ $rgname = Get-ResourceGroupName
23
+ $circuitName = Get-ResourceName
24
+ $rglocation = Get-ProviderLocation ResourceManagement
25
+ $resourceTypeParent = " Microsoft.Network/expressRouteCircuits"
26
+ $location = Get-ProviderLocation $resourceTypeParent
27
+ $location = " brazilSouth"
28
+ try
29
+ {
30
+ # Create the resource group
31
+ $resourceGroup = New-AzureRmResourceGroup - Name $rgname - Location $rglocation
32
+
33
+ # Create the ExpressRouteCircuit
34
+ $circuit = New-AzureRmExpressRouteCircuit - Name $circuitName - Location $location - ResourceGroupName $rgname - SkuName " standard_meteredData" - SkuTier Standard - SkuFamily MeteredData - ServiceProviderName " equinix" - PeeringLocation " Silicon Valley" - BandwidthInMbps 1000 ;
35
+
36
+ # get Circuit
37
+ $getCircuit = Get-AzureRmExpressRouteCircuit - Name $circuitName - ResourceGroupName $rgname
38
+
39
+ # verification
40
+ Assert-AreEqual $rgName $getCircuit.ResourceGroupName
41
+ Assert-AreEqual $circuitName $getCircuit.Name
42
+ Assert-NotNull $getCircuit.Location
43
+ Assert-NotNull $getCircuit.Etag
44
+ Assert-AreEqual 0 @ ($getCircuit.Peerings ).Count
45
+ Assert-AreEqual " standard_meteredData" $getCircuit.Sku.Name
46
+ Assert-AreEqual " Standard" $getCircuit.Sku.Tier
47
+ Assert-AreEqual " MeteredData" $getCircuit.Sku.Family
48
+ Assert-AreEqual " equinix" $getCircuit.ServiceProviderProperties.ServiceProviderName
49
+ Assert-AreEqual " Silicon Valley" $getCircuit.ServiceProviderProperties.PeeringLocation
50
+ Assert-AreEqual " 1000" $getCircuit.ServiceProviderProperties.BandwidthInMbps
51
+
52
+ # list
53
+ $list = Get-AzureRmExpressRouteCircuit - ResourceGroupName $rgname
54
+ Assert-AreEqual 1 @ ($list ).Count
55
+ Assert-AreEqual $list [0 ].ResourceGroupName $getCircuit.ResourceGroupName
56
+ Assert-AreEqual $list [0 ].Name $getCircuit.Name
57
+ Assert-AreEqual $list [0 ].Location $getCircuit.Location
58
+ Assert-AreEqual $list [0 ].Etag $getCircuit.Etag
59
+ Assert-AreEqual @ ($list [0 ].Peerings).Count @ ($getCircuit.Peerings ).Count
60
+
61
+ # set
62
+ $getCircuit.ServiceProviderProperties.BandwidthInMbps = 500
63
+
64
+ $getCircuit = $getCircuit | Set-AzureRmExpressRouteCircuit
65
+ Assert-AreEqual $rgName $getCircuit.ResourceGroupName
66
+ Assert-AreEqual $circuitName $getCircuit.Name
67
+ Assert-NotNull $getCircuit.Location
68
+ Assert-NotNull $getCircuit.Etag
69
+ Assert-AreEqual 0 @ ($getCircuit.Peerings ).Count
70
+ Assert-AreEqual " standard_meteredData" $getCircuit.Sku.Name
71
+ Assert-AreEqual " Standard" $getCircuit.Sku.Tier
72
+ Assert-AreEqual " MeteredData" $getCircuit.Sku.Family
73
+ Assert-AreEqual " equinix" $getCircuit.ServiceProviderProperties.ServiceProviderName
74
+ Assert-AreEqual " Silicon Valley" $getCircuit.ServiceProviderProperties.PeeringLocation
75
+ Assert-AreEqual " 500" $getCircuit.ServiceProviderProperties.BandwidthInMbps
76
+
77
+ # Delete Circuit
78
+ $delete = Remove-AzureRmExpressRouteCircuit - ResourceGroupName $rgname - name $circuitName - PassThru - Force
79
+ Assert-AreEqual true $delete
80
+
81
+ $list = Get-AzureRmExpressRouteCircuit - ResourceGroupName $rgname
82
+ Assert-AreEqual 0 @ ($list ).Count
83
+ }
84
+ finally
85
+ {
86
+ # Cleanup
87
+ Clean - ResourceGroup $rgname
88
+ }
89
+ }
90
+
91
+ <#
92
+ . SYNOPSIS
93
+ Tests ExpressRouteCircuitPeeringCRUD.
94
+ #>
95
+ function Test-ExpressRouteCircuitPeeringCRUD
96
+ {
97
+ # Setup
98
+ $rgname = Get-ResourceGroupName
99
+ $circuitName = Get-ResourceName
100
+ $rglocation = Get-ProviderLocation ResourceManagement
101
+ $resourceTypeParent = " Microsoft.Network/expressRouteCircuits"
102
+ $location = Get-ProviderLocation $resourceTypeParent
103
+ $location = " brazilSouth"
104
+ try
105
+ {
106
+ # Create the resource group
107
+ $resourceGroup = New-AzureRmResourceGroup - Name $rgname - Location $rglocation
108
+
109
+ # Create the ExpressRouteCircuit with peering
110
+ $peering = New-AzureRmExpressRouteCircuitPeeringConfig - Name AzurePrivatePeering - PeeringType AzurePrivatePeering - PeerASN 100 - PrimaryPeerAddressPrefix " 192.168.1.0/30" - SecondaryPeerAddressPrefix " 192.168.2.0/30" - VlanId 200
111
+ $circuit = New-AzureRmExpressRouteCircuit - Name $circuitName - Location $location - ResourceGroupName $rgname - SkuName " standard_meteredData" - SkuTier Standard - SkuFamily MeteredData - ServiceProviderName " equinix" - PeeringLocation " Silicon Valley" - BandwidthInMbps 1000 - Peering $peering
112
+
113
+ # verification
114
+ Assert-AreEqual $rgName $circuit.ResourceGroupName
115
+ Assert-AreEqual $circuitName $circuit.Name
116
+ Assert-NotNull $circuit.Location
117
+ Assert-NotNull $circuit.Etag
118
+ Assert-AreEqual 1 @ ($circuit.Peerings ).Count
119
+ Assert-AreEqual " standard_meteredData" $circuit.Sku.Name
120
+ Assert-AreEqual " Standard" $circuit.Sku.Tier
121
+ Assert-AreEqual " MeteredData" $circuit.Sku.Family
122
+ Assert-AreEqual " equinix" $circuit.ServiceProviderProperties.ServiceProviderName
123
+ Assert-AreEqual " Silicon Valley" $circuit.ServiceProviderProperties.PeeringLocation
124
+ Assert-AreEqual " 1000" $circuit.ServiceProviderProperties.BandwidthInMbps
125
+
126
+ # Verify the peering
127
+ Assert-AreEqual " AzurePrivatePeering" $circuit.Peerings [0 ].Name
128
+ Assert-AreEqual " AzurePrivatePeering" $circuit.Peerings [0 ].PeeringType
129
+ Assert-AreEqual " 100" $circuit.Peerings [0 ].PeerASN
130
+ Assert-AreEqual " 192.168.1.0/30" $circuit.Peerings [0 ].PrimaryPeerAddressPrefix
131
+ Assert-AreEqual " 192.168.2.0/30" $circuit.Peerings [0 ].SecondaryPeerAddressPrefix
132
+ Assert-AreEqual " 200" $circuit.Peerings [0 ].VlanId
133
+
134
+ # get peering
135
+ $p = $circuit | Get-AzureRmExpressRouteCircuitPeeringConfig - Name AzurePrivatePeering
136
+ Assert-AreEqual " AzurePrivatePeering" $p.Name
137
+ Assert-AreEqual " AzurePrivatePeering" $p.PeeringType
138
+ Assert-AreEqual " 100" $p.PeerASN
139
+ Assert-AreEqual " 192.168.1.0/30" $p.PrimaryPeerAddressPrefix
140
+ Assert-AreEqual " 192.168.2.0/30" $p.SecondaryPeerAddressPrefix
141
+ Assert-AreEqual " 200" $p.VlanId
142
+ Assert-Null $p.MicrosoftPeeringConfig
143
+
144
+ # List peering
145
+ $listPeering = $circuit | Get-AzureRmExpressRouteCircuitPeeringConfig
146
+ Assert-AreEqual 1 @ ($listPeering ).Count
147
+
148
+ # add a new Peering
149
+ $circuit = Get-AzureRmExpressRouteCircuit - Name $circuitName - ResourceGroupName $rgname | Add-AzureRmExpressRouteCircuitPeeringConfig - Name MicrosoftPeering - PeeringType MicrosoftPeering - PeerASN 99 - PrimaryPeerAddressPrefix " 192.168.1.0/30" - SecondaryPeerAddressPrefix " 192.168.2.0/30" - VlanId 200 - MircosoftConfigAdvertisedPublicPrefixes @ (" 11.2.3.4/30" , " 12.2.3.4/30" ) - MircosoftConfigCustomerAsn 1000 - MircosoftConfigRoutingRegistryName AFRINIC | Set-AzureRmExpressRouteCircuit
150
+
151
+ $p = $circuit | Get-AzureRmExpressRouteCircuitPeeringConfig - Name MicrosoftPeering
152
+ Assert-AreEqual " MicrosoftPeering" $p.Name
153
+ Assert-AreEqual " MicrosoftPeering" $p.PeeringType
154
+ Assert-AreEqual " 99" $p.PeerASN
155
+ Assert-AreEqual " 192.168.1.0/30" $p.PrimaryPeerAddressPrefix
156
+ Assert-AreEqual " 192.168.2.0/30" $p.SecondaryPeerAddressPrefix
157
+ Assert-AreEqual " 200" $p.VlanId
158
+ Assert-NotNull $p.MicrosoftPeeringConfig
159
+ Assert-AreEqual " 1000" $p.MicrosoftPeeringConfig.CustomerASN
160
+ Assert-AreEqual " AFRINIC" $p.MicrosoftPeeringConfig.RoutingRegistryName
161
+ Assert-AreEqual 2 @ ($p.MicrosoftPeeringConfig.AdvertisedPublicPrefixes ).Count
162
+ Assert-NotNull $p.MicrosoftPeeringConfig.AdvertisedPublicPrefixesState
163
+
164
+ $listPeering = $circuit | Get-AzureRmExpressRouteCircuitPeeringConfig
165
+ Assert-AreEqual 2 @ ($listPeering ).Count
166
+
167
+ # Set a new peering
168
+ $circuit = Get-AzureRmExpressRouteCircuit - Name $circuitName - ResourceGroupName $rgname | Set-AzureRmExpressRouteCircuitPeeringConfig - Name MicrosoftPeering - PeeringType MicrosoftPeering - PeerASN 100 - PrimaryPeerAddressPrefix " 192.168.1.0/30" - SecondaryPeerAddressPrefix " 192.168.2.0/30" - VlanId 200 - MircosoftConfigAdvertisedPublicPrefixes @ (" 11.2.3.4/30" , " 12.2.3.4/30" ) - MircosoftConfigCustomerAsn 1000 - MircosoftConfigRoutingRegistryName AFRINIC | Set-AzureRmExpressRouteCircuit
169
+ $p = $circuit | Get-AzureRmExpressRouteCircuitPeeringConfig - Name MicrosoftPeering
170
+ Assert-AreEqual " MicrosoftPeering" $p.Name
171
+ Assert-AreEqual " MicrosoftPeering" $p.PeeringType
172
+ Assert-AreEqual " 100" $p.PeerASN
173
+ Assert-AreEqual " 192.168.1.0/30" $p.PrimaryPeerAddressPrefix
174
+ Assert-AreEqual " 192.168.2.0/30" $p.SecondaryPeerAddressPrefix
175
+ Assert-AreEqual " 200" $p.VlanId
176
+ Assert-NotNull $p.MicrosoftPeeringConfig
177
+ Assert-AreEqual " 1000" $p.MicrosoftPeeringConfig.CustomerASN
178
+ Assert-AreEqual " AFRINIC" $p.MicrosoftPeeringConfig.RoutingRegistryName
179
+ Assert-AreEqual 2 @ ($p.MicrosoftPeeringConfig.AdvertisedPublicPrefixes ).Count
180
+ Assert-NotNull $p.MicrosoftPeeringConfig.AdvertisedPublicPrefixesState
181
+
182
+ # Delete Circuit
183
+ $delete = Remove-AzureRmExpressRouteCircuit - ResourceGroupName $rgname - name $circuitName - PassThru - Force
184
+ Assert-AreEqual true $delete
185
+
186
+ $list = Get-AzureRmExpressRouteCircuit - ResourceGroupName $rgname
187
+ Assert-AreEqual 0 @ ($list ).Count
188
+ }
189
+ finally
190
+ {
191
+ # Cleanup
192
+ Clean - ResourceGroup $rgname
193
+ }
194
+ }
0 commit comments