-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathBlobStorageLatencyTest.ps1
More file actions
78 lines (59 loc) · 2.19 KB
/
BlobStorageLatencyTest.ps1
File metadata and controls
78 lines (59 loc) · 2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
Connect-AzAccount
$blobUri = "YOUR_BLOB_URI"
#Download blob
$iterations = 100
$stopwatch = [System.Diagnostics.Stopwatch]::new()
$origProgressPref = $ProgressPreference
$rawResults = [System.Collections.ArrayList]::new()
$regionResult = @{
PSTypeName = 'AzureRegionLatencyResult'
Region = 'westeurope'
ComputerName = $env:COMPUTERNAME
}
$ProgressPreference = 'SilentlyContinue'
for ($i = 0; $i -lt $iterations; $i++) {
$stopwatch.Start()
Invoke-WebRequest -Uri $blobUri -UseBasicParsing > $null
$stopwatch.Stop()
$rawResults.Add($stopwatch.ElapsedMilliseconds) > $null
$stopwatch.Reset()
}
$ProgressPreference = $origProgressPref
$regionResult.Average = ($rawResults | Measure-Object -Average).Average
$regionResult.Minimum = ($rawResults | Measure-Object -Minimum).Minimum
$regionResult.Maximum = ($rawResults | Measure-Object -Maximum).Maximum
$finalResult = [PSCustomObject]$regionResult
$finalResult
#UPLOAD BLOB
$StorageAccount = "YOURSTORAGEACCOUNT";
$ContainerName = "YOURCONTAINERNAME";
$Context = New-AzStorageContext -StorageAccountName $StorageAccount -UseConnectedAccount
$Blob = @{
File = 'C:\Temp\test.pdf'
Container = $ContainerName
Blob = 'test.pdf'
Context = $Context
}
$iterations = 100
$stopwatch = [System.Diagnostics.Stopwatch]::new()
$origProgressPref = $ProgressPreference
$rawResults = [System.Collections.ArrayList]::new()
$regionResult = @{
PSTypeName = 'AzureRegionLatencyResult'
Region = 'westeurope'
ComputerName = $env:COMPUTERNAME
}
$ProgressPreference = 'SilentlyContinue'
for ($i = 0; $i -lt $iterations; $i++) {
$stopwatch.Start()
Set-AzStorageBlobContent @Blob -Force
$stopwatch.Stop()
$rawResults.Add($stopwatch.ElapsedMilliseconds) > $null
$stopwatch.Reset()
}
$ProgressPreference = $origProgressPref
$regionResult.Average = ($rawResults | Measure-Object -Average).Average
$regionResult.Minimum = ($rawResults | Measure-Object -Minimum).Minimum
$regionResult.Maximum = ($rawResults | Measure-Object -Maximum).Maximum
$finalResult = [PSCustomObject]$regionResult
$finalResult