This repository has been archived by the owner on Feb 10, 2024. It is now read-only.
forked from vanderbilt-redcap/redcap-azure
-
Notifications
You must be signed in to change notification settings - Fork 3
/
ARMDeployment.ps1
80 lines (63 loc) · 2.64 KB
/
ARMDeployment.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
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
$startTime=Get-Date
Write-Host "Beginning deployment at $starttime"
Import-Module Azure -ErrorAction SilentlyContinue
$version = 0;
#DEPLOYMENT OPTIONS
#Please review the azuredeploy.json file for available options
$RGName = "<YOUR RESOURCE GROUP>"
$DeployRegion = "<SELECT AZURE REGION>"
$AssetLocation = "https://github.com/vanderbilt-redcap/redcap-azure/blob/master/azuredeploy.json"
$parms = @{
#Make your ZIP file temporarily accessible via a public file share
"redcapAppZip" = "<path to your copy of the REDCap distribution ZIP file>";
#Azure Web App
"siteName" = "<WEB SITE NAME, like 'redcap'>";
"skuName" = "S1";
#MySQL
"administratorLogin" = "<MySQL admin account name>";
"administratorLoginPassword" = "<MySQL admin login password>";
"databaseSkuSizeMB" = 5120;
"databaseForMySqlTier" = "GeneralPurpose";
"databaseForMySqlFamily" = "Gen5";
"databaseForMySqlCores" = 2;
"mysqlVersion" = "5.7";
#Azure Storage
"storageType" = "Standard_LRS";
"storageContainerName" = "redcap";
#GitHub
"repoURL" = "https://github.com/vanderbilt-redcap/redcap-azure.git";
"branch" = "master";
}
#END DEPLOYMENT OPTIONS
#Dot-sourced variable override (optional, comment out if not using)
$dotsourceSettings = "$($env:PSH_Settings_Files)redcap-azure.ps1"
if (Test-Path $dotsourceSettings) {
. $dotsourceSettings
}
#ensure we're logged in
Get-AzureRmContext -ErrorAction Stop
#deploy
$TemplateFile = "$($AssetLocation)?x=$version"
try {
Get-AzureRmResourceGroup -Name $RGName -ErrorAction Stop
Write-Host "Resource group $RGName exists, updating deployment"
}
catch {
$RG = New-AzureRmResourceGroup -Name $RGName -Location $DeployRegion
Write-Host "Created new resource group $RGName."
}
$version ++
$deployment = New-AzureRmResourceGroupDeployment -ResourceGroupName $RGName -TemplateParameterObject $parms -TemplateFile $TemplateFile -Name "RedCAPDeploy$version" -Force -Verbose
if ($deployment.ProvisioningState -eq "Succeeded") {
$siteName = $deployment.Outputs.webSiteFQDN.Value
start "https://$($siteName)/AzDeployStatus.php"
Write-Host "---------"
$deployment.Outputs | ConvertTo-Json
} else {
$deperr = Get-AzureRmResourceGroupDeploymentOperation -DeploymentName "RedCAPDeploy$version" -ResourceGroupName $RGName
$deperr | ConvertTo-Json
}
$endTime=Get-Date
Write-Host ""
Write-Host "Total Deployment time:"
New-TimeSpan -Start $startTime -End $endTime | Select Hours, Minutes, Seconds