@@ -15,7 +15,58 @@ if(($null -eq $TestName) -or ($TestName -contains 'Get-AzCdnEndpointResourceUsag
15
15
}
16
16
17
17
Describe ' Get-AzCdnEndpointResourceUsage' {
18
- It ' List' - skip {
19
- { throw [System.NotImplementedException ] } | Should -Not - Throw
18
+ It ' List' {
19
+ {
20
+ $ResourceGroupName = ' testps-rg-' + (RandomString - allChars $false - len 6 )
21
+ try
22
+ {
23
+ Write-Host - ForegroundColor Green " Create test group $ ( $ResourceGroupName ) "
24
+ New-AzResourceGroup - Name $ResourceGroupName - Location $env.location
25
+
26
+ $cdnProfileName = ' p-' + (RandomString - allChars $false - len 6 );
27
+ Write-Host - ForegroundColor Green " Use cdnProfileName : $ ( $cdnProfileName ) "
28
+
29
+ $profileSku = " Standard_Akamai" ;
30
+ New-AzCdnProfile - SkuName $profileSku - Name $cdnProfileName - ResourceGroupName $ResourceGroupName - Location Global
31
+
32
+ $endpointName = ' e-' + (RandomString - allChars $false - len 6 );
33
+ $origin = @ {
34
+ Name = " origin1"
35
+ HostName = " host1.hello.com"
36
+ };
37
+ $location = " westus"
38
+ Write-Host - ForegroundColor Green " Create endpointName : $ ( $endpointName ) , origin.Name : $ ( $origin.Name ) , origin.HostName : $ ( $origin.HostName ) "
39
+
40
+ New-AzCdnEndpoint - Name $endpointName - ResourceGroupName $ResourceGroupName - ProfileName $cdnProfileName - Location $location - Origin $origin
41
+ $endpointResourceUsages = Get-AzCdnEndpointResourceUsage - EndpointName $endpointName - ProfileName $cdnProfileName - ResourceGroupName $ResourceGroupName
42
+ $geofilterUsage = $endpointResourceUsages | Where-Object - Property ResourceType -eq ' geofilter'
43
+
44
+ $endpointResourceUsages.Count | Should - Be 3
45
+ $geofilterUsage.Limit | Should - Be 25
46
+ $geofilterUsage.CurrentValue | Should - Be 0
47
+
48
+ $geofilters = @ (
49
+ @ {
50
+ RelativePath = " /mycar"
51
+ Action = [Microsoft.Azure.PowerShell.Cmdlets.Cdn.Support.GeoFilterActions ]::Allow
52
+ CountryCode = " AU"
53
+ },
54
+ @ {
55
+ RelativePath = " /mycars"
56
+ Action = [Microsoft.Azure.PowerShell.Cmdlets.Cdn.Support.GeoFilterActions ]::Allow
57
+ CountryCode = " AU"
58
+ })
59
+ Update-AzCdnEndpoint - Name $endpointName - ResourceGroupName $ResourceGroupName - ProfileName $cdnProfileName - GeoFilter $geofilters
60
+ $endpointResourceUsages = Get-AzCdnEndpointResourceUsage - EndpointName $endpointName - ProfileName $cdnProfileName - ResourceGroupName $ResourceGroupName
61
+ $geofilterUsage = $endpointResourceUsages | Where-Object - Property ResourceType -eq ' geofilter'
62
+
63
+ $endpointResourceUsages.Count | Should - Be 3
64
+ $geofilterUsage.Limit | Should - Be 25
65
+ $geofilterUsage.CurrentValue | Should - Be 2
66
+ } Finally
67
+ {
68
+ Remove-AzResourceGroup - Name $ResourceGroupName - NoWait
69
+ }
70
+ } | Should -Not - Throw
20
71
}
21
72
}
0 commit comments