|
1 |
| -param ( |
2 |
| - [Parameter(Mandatory, Position = 0)] |
3 |
| - [ValidateNotNullOrEmpty()] |
4 |
| - [guid] $TenantId, |
| 1 | +$ltResults = Get-ChildItem -Path ${env:DATALOCATION} -Filter "LiveTestAnalysis" -Directory -Recurse -ErrorAction SilentlyContinue | Get-ChildItem -Filter "Raw" -Directory | Get-ChildItem -Filter "*.csv" -File | Select-Object -ExpandProperty FullName |
| 2 | +if ($null -ne $ltResults) { |
| 3 | + Write-Host "##[group]Start uploading live test results." |
5 | 4 |
|
6 |
| - [Parameter(Mandatory, Position = 1)] |
7 |
| - [ValidateNotNullOrEmpty()] |
8 |
| - [guid] $ServicePrincipalId, |
| 5 | + $localDate = [DateTime]::UtcNow.AddHours(8).ToString("yyyy-MM-dd") |
| 6 | + $context = New-AzStorageContext -StorageAccountName ${env:STORAGEACCOUNTNAME} |
| 7 | + $ltResults | ForEach-Object { |
| 8 | + $ltCsv = $_ |
| 9 | + $ltCsvCore = Split-Path -Path $ltCsv -Parent | Split-Path -Parent | Split-Path -Parent | Split-Path -Leaf |
| 10 | + $ltCsvName = Split-Path -Path $ltCsv -Leaf |
| 11 | + Set-AzStorageBlobContent -Container ${env:STORAGEBLOBCONTAINERNAME} -Blob "$localDate/$ltCsvCore/$ltCsvName" -File $ltCsv -Context $context -Force |
9 | 12 |
|
10 |
| - [Parameter(Mandatory, Position = 2)] |
11 |
| - [ValidateNotNullOrEmpty()] |
12 |
| - [string] $ServicePrincipalSecret, |
| 13 | + Write-Host "##[section]Uploaded live test result $ltCsv." |
| 14 | + } |
13 | 15 |
|
14 |
| - [Parameter(Mandatory, Position = 3)] |
15 |
| - [ValidateNotNullOrEmpty()] |
16 |
| - [string] $ClusterName, |
17 |
| - |
18 |
| - [Parameter(Mandatory, Position = 4)] |
19 |
| - [ValidateNotNullOrEmpty()] |
20 |
| - [string] $ClusterRegion |
21 |
| -) |
22 |
| - |
23 |
| -$ltDir = Join-Path -Path ${env:DATALOCATION} -ChildPath "LiveTestAnalysis" | Join-Path -ChildPath "Raw" |
24 |
| -$ltResults = Get-ChildItem -Path $ltDir -Filter "*.csv" -File -ErrorAction SilentlyContinue | Select-Object -ExpandProperty FullName |
25 |
| - |
26 |
| -if (![string]::IsNullOrEmpty($ltResults)) { |
27 |
| - Import-Module "./tools/TestFx/Utilities/KustoUtility.psd1" -ArgumentList $TenantId, $ServicePrincipalId, $ServicePrincipalSecret, $ClusterName, $ClusterRegion -Force |
28 |
| - Add-KustoData -DatabaseName ${env:LIVETESTDATABASENAME} -TableName ${env:LIVETESTTABLENAME} -CsvFile $ltResults |
29 |
| -} |
30 |
| -else { |
31 |
| - Write-Host "##[warning]No live test data was found." |
| 16 | + Write-Host "##[endgroup]" |
32 | 17 | }
|
0 commit comments