forked from devopsshield/devsecops-workshop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Validate-Deployment.ps1
45 lines (37 loc) · 1.31 KB
/
Validate-Deployment.ps1
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
param (
[Parameter()]
[string]$nameSuffix = "ek002",
[Parameter()]
[string]$deploymentName = "deploy-rg-fnapp-$nameSuffix",
[Parameter()]
[string]$resourceGroupName = "rg-fnapp-$nameSuffix"
)
# echo parameters
Write-Host "deploymentName: $deploymentName"
Write-Host "nameSuffix: $nameSuffix"
Write-Host "resourceGroupName: $resourceGroupName"
#az account show
# get functionAppName
$functionAppName = az deployment group show --resource-group $resourceGroupName `
--name $deploymentName `
--query properties.outputs.azureFunctionName.value `
-o tsv
Write-Host "functionAppName: $functionAppName"
# get testUrl with function key
$functionKey = az functionapp keys list --name $functionAppName `
--resource-group $resourceGroupName `
--query functionKeys.default `
-o tsv
Write-Host "functionKey: $functionKey"
$addNameParameter = $true
if ($addNameParameter) {
Write-Host "Adding name parameter to testUrl"
$testUrl = "https://$functionAppName.azurewebsites.net/api/HttpExample?name=AzureDevOpsSmokeTest&code=$functionKey"
}
else {
$testUrl = "https://$functionAppName.azurewebsites.net/api/HttpExample?code=$functionKey"
}
Write-Host "testUrl: $testUrl"
# test function
$testResult = Invoke-RestMethod -Uri $testUrl
Write-Host "testResult: $testResult"