This repository was archived by the owner on Jan 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestExample.ps1
More file actions
51 lines (35 loc) · 2.18 KB
/
TestExample.ps1
File metadata and controls
51 lines (35 loc) · 2.18 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
param(
[Parameter(Mandatory = $True)][string]$Path,
[Parameter(Mandatory = $True)][string]$BuildConfig,
[Parameter(Mandatory = $True)][string]$ReportDir,
[Parameter(Mandatory = $True)][string]$EnvironmentPath,
[Parameter(Mandatory = $True)][string]$Name,
[Parameter(Mandatory = $True)][string]$ResourceGroupName,
[Parameter(Mandatory = $True)][string]$Location)
$WorkingDirectory = "$Path\Examples\Eklee.Azure.Functions.Http.Example\bin\$BuildConfig\netstandard2.1"
$StackName = ($Name + $env:Build_BuildNumber).Replace(".", "")
Compress-Archive -Path "$WorkingDirectory\*" -DestinationPath "$WorkingDirectory\Deploy.zip"
Write-Host "Running deployment $StackName"
az deployment group create `
--name $StackName `
--resource-group $ResourceGroupName `
--template-file Templates/app.json `
--parameters plan_name=$StackName location=$Location | Out-Null
Write-Host "Configure app settings"
$content = Get-Content -Path "$Path\Examples\Eklee.Azure.Functions.Http.Example\local.settings.json" | ConvertFrom-Json
$audience = $content.Values.Audience
$issuers = $content.Values.Issuers
az functionapp config appsettings set -n $StackName -g $ResourceGroupName --settings "Audience=$audience" "Issuers=$issuers" | Out-Null
Write-Host "Deploying code"
az functionapp deployment source config-zip -g $ResourceGroupName -n $StackName --src "$WorkingDirectory\Deploy.zip" | Out-Null
Write-Host "Installing newman"
Push-Location $WorkingDirectory
npm install --save-dev newman
Pop-Location
Write-Host "Running postman"
$content = (Get-Content -Path "$Path\Tests\Eklee.Azure.Functions.Http.Local.postman_environment.json").Replace("http://localhost:7071", "https://$StackName.azurewebsites.net")
$content | Out-File "$Path\Tests\Eklee.Azure.Functions.Http.Local.postman_environment.json" -Encoding ASCII
$reportFilePath = "$ReportDir/report.xml"
Push-Location $Path\Examples\Eklee.Azure.Functions.Http.Example\bin\$BuildConfig\netstandard2.1
node_modules\.bin\newman run "$EnvironmentPath\Tests\Eklee.Azure.Functions.Http.Tests.postman_collection.json" -e "$EnvironmentPath\Tests\Eklee.Azure.Functions.Http.Local.postman_environment.json" --reporters 'cli,junit' --reporter-junit-export $reportFilePath
Pop-Location