Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ fabric.properties

### PowerShell template
# Exclude packaged modules
*.zip
#*.zip

# Exclude .NET assemblies from source
*.dll
Expand Down
63 changes: 63 additions & 0 deletions scripts/webapp/webapp_check_service_status.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
param (
[Parameter(
Mandatory = $true,
HelpMessage = "The health endpoint to poll."
)]
[ValidateNotNullOrEmpty()]
[string]$HealthEndpointUrl,

[Parameter(
Mandatory = $true,
HelpMessage = "The maximum length of time to wait for a successful response."
)]
[ValidateRange(1, 30)]
[int]$WaitTimeInMinutes
)

$sleepTimeInSeconds = 15
$isServiceActive = $false
$stopWatch = New-Object -TypeName System.Diagnostics.Stopwatch
$timeSpan = New-TimeSpan -Minutes $WaitTimeInMinutes
$stopWatch.Start()

do {
Write-Host "Polling $HealthEndpointUrl..."

try {
$httpRequest = [System.Net.WebRequest]::Create("$HealthEndpointUrl")
$httpResponse = $httpRequest.GetResponse()
$httpStatus = $httpResponse.StatusCode
Write-Host "Status code is $httpStatus"

If ($httpStatus -eq 200 ) {
Write-Host "Service is healthy - stopping polling..."
$isServiceActive = $true
break
} else {
Write-Host "Service not yet healthy. Status code is $httpStatus. Re-checking in $sleepTimeInSeconds seconds..."
}
}
catch [System.Net.WebException] {
$httpStatus = $_.Exception.Response.StatusCode
Write-Host "Service not yet healthy. Status code is $httpStatus. Re-checking in $sleepTimeInSeconds seconds..."
}

Start-Sleep -Seconds $sleepTimeInSeconds
} until ($stopWatch.Elapsed -ge $timeSpan)

if ($httpResponse -ne $null) {
$httpResponse.Close()
}

if ($isServiceActive -eq $true ) {
Write-Host "Health check successful"
} else {

if ($WaitTimeInMinutes -eq 1) {
Write-Error "Health check unsuccessful after $WaitTimeInMinutes minute"
} else {
Write-Error "Health check unsuccessful after $WaitTimeInMinutes minutes"
}

throw "Error"
}
17 changes: 17 additions & 0 deletions tasks/file_transform.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/microsoft/azure-pipelines-vscode/master/service-schema.json

parameters:
- name: FolderPath
type: string
displayName: File path to the package or a folder. Wildcards are supported.

- name: JsonTargetFiles
type: string
displayName: A newline-separated list of files to substitute the variable values.

steps:
- task: FileTransform@2
displayName: File Transform
inputs:
folderPath: ${{ parameters.FolderPath }}
jsonTargetFiles: ${{ parameters.JsonTargetFiles }}
29 changes: 29 additions & 0 deletions tasks/webapp_deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/microsoft/azure-pipelines-vscode/master/service-schema.json

parameters:
- name: AzureSubscription
type: string
displayName: Specifies the Azure Resource Manager subscription connection for the deployment.

- name: WebAppName
type: string
displayName: Specifies the name of an Azure App Service.

- name: SlotName
type: string
displayName: Specifies an existing slot, excluding the production slot.

- name: Package
type: string
displayName: The file path to the package or folder that contains App Service content.

steps:
- task: AzureWebApp@1
displayName: Deploy Web App
inputs:
azureSubscription: ${{ parameters.AzureSubscription }}
appType: webApp
appName: ${{ parameters.WebAppName }}
deployToSlotOrASE: true
slotName: ${{ parameters.SlotName }}
package: ${{ parameters.Package }}
Binary file added tests/UKHO.test_app.Api.zip
Binary file not shown.