-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathDeploy-HMAsWebJob.ps1
More file actions
100 lines (80 loc) · 3.27 KB
/
Deploy-HMAsWebJob.ps1
File metadata and controls
100 lines (80 loc) · 3.27 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
param(
[Parameter(Mandatory = $true)]
[string]$slot,
[Parameter(Mandatory = $true)]
[string]$buildConfiguration
)
$ErrorActionPreference = 'Stop'
$rootDir = Split-Path -parent $PSCommandPath
$archiveFolderName = "$rootDir\HM-WebJob-Archive"
$outputArchiveFile = "$rootDir\HM-azurewebsitejob.zip"
# Check if archive folder exists, remove if it does.
If (Test-Path $archiveFolderName){
Write-Host "Removing old $archiveFolderName folder"
Remove-Item $archiveFolderName -Force -Recurse
}
# Check if previous archive file exists, remove if it does.
If (Test-Path $outputArchiveFile){
Write-Host "Removing old $outputArchiveFile archive file"
Remove-Item $outputArchiveFile -Force -Recurse
}
# Create archive folder.
New-Item -ItemType Directory -Force -Path $archiveFolderName | Out-Null
# Create SQL folder
New-Item -ItemType Directory -Force -Path $archiveFolderName\SQL | Out-Null
# Create Config\HealthMonitor folder
New-Item -ItemType Directory -Force -Path $archiveFolderName\Config | Out-Null
New-Item -ItemType Directory -Force -Path $archiveFolderName\Config\HealthMonitor | Out-Null
# Copy HealthMonitor DLLs to archive folder.
$srcFiles = "$rootDir\..\Tests\HealthMonitor\bin\$($buildConfiguration)\*"
$exclude = @("HealthMonitor.vshost.exe", "HealthMonitor.vshost.exe.config", "HealthMonitor.vshost.exe.manifest")
Copy-Item $srcFiles -Destination $archiveFolderName -Exclude $exclude -Force -Recurse
# Copy settings.job to archive folder.
$srcSettingsFile = "$rootDir\HM-job-settings.job"
$dstSettingsFile = "$archiveFolderName\settings.job"
Copy-Item $srcSettingsFile -Destination $dstSettingsFile -Force
# Copy run.cmd to archive folder
$srcRunFile = "$rootDir\HM-job-run.cmd"
$dstRunFile = "$archiveFolderName\run.cmd"
Copy-Item $srcRunFile -Destination $dstRunFile -Force
# Copy SQL folder
$srcRunFile = "$rootDir\..\Tests\HealthMonitor\SQL\*"
$dstRunFile = "$archiveFolderName\SQL\"
Copy-Item $srcRunFile -Destination $dstRunFile -Force
# Copy Config
$srcRunFile = "$rootDir\..\Tests\HealthMonitor\Config\*"
$dstRunFile = "$archiveFolderName\Config\"
Copy-Item $srcRunFile -Destination $dstRunFile -Force
# Fix the file argument
$configFile = $archiveFolderName + "\HealthMonitor.exe.config"
$xml = [xml](Get-Content ($configFile))
$node = $xml.configuration.appSettings
if ($node -ne $NULL)
{
$node.file = "Config\Settings.config"
$xml.Save($configFile)
}
# Copy PowerShell script
$srcRunFile = "$rootDir\CleanUpAfterTests.ps1"
$dstRunFile = "$archiveFolderName\"
Copy-Item $srcRunFile -Destination $dstRunFile -Force
# Create zip archive.
$archiveFiles = "$archiveFolderName\*"
Compress-Archive -Path $archiveFiles -DestinationPath $outputArchiveFile -Force
# Create zip archive.
$archiveFiles = "$archiveFolderName\*"
Compress-Archive -Path $archiveFiles -DestinationPath $outputArchiveFile -Force
# Deploy AzureWebsiteJob.
Write-Host "Deploying Azure WebJob"
$site = Get-AzureWebsite -Name "fr8" -Slot $slot
# $site = Get-AzureWebsite -Name "fr8dev"
New-AzureWebsiteJob -Name $site[0].Name `
-JobName "HealthMonitor" `
-JobType Triggered `
-JobFile $outputArchiveFile `
-Slot $slot;
# Remove zip archive.
# Write-Host "Removing current deployment zip archive"
# Remove-Item $outputArchiveFile -Force -Recurse
# Remove current archive folder.
Remove-Item $archiveFolderName -Force -Recurse