-
Notifications
You must be signed in to change notification settings - Fork 6
/
deploy-xm1-continuous.ps1
82 lines (64 loc) · 3 KB
/
deploy-xm1-continuous.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
81
82
#
# Deploys a Sitecore ms deploy (web deploy) package to Sitecore 8.2u5 CD and CM slots
# Makes assumptions that both the keyvault and slots addon where configured and deployed
# Most information is inferred automatically from keyvault and deployment output params
# These should have been provisioned by "./deploy-xm-initial.ps1"
# Eventually this script calls into the more generic version "deploy-xm1-continuous-generic.ps1"
#
[CmdletBinding()]
Param(
[Parameter(Mandatory=$True)]
[string]$SubscriptionName,
[Parameter(Mandatory=$True)]
[string]$RGName,
[Parameter(Mandatory=$True)]
[string]$PackageLocation,
[Parameter(Mandatory=$True)]
[string]$ParamsFileLocation,
[Parameter(Mandatory=$False)]
[string]$ArtifactsRootDir,
[Parameter(Mandatory=$False)]
[string]$TempFolderName, #needed in the generic script to save the publish profile to
[Parameter(Mandatory=$True)]
[ValidateSet('CM','CD')]
[string]$Role,
[Parameter(Mandatory=$false)]
[switch]$DoNotDeleteExistingFiles = $false,
[Parameter(Mandatory=$false)]
[switch]$SkipDbOperations = $false
)
$ErrorActionPreference = "Stop"
#when running local code, use relative path to script, if on VSTS, the artifacts dir is different
if ($ArtifactsRootDir){
$scriptDir = $ArtifactsRootDir
}else{
$scriptDir = Split-Path $MyInvocation.MyCommand.Path
}
# Select Subscription:
Get-AzureRmSubscription -SubscriptionName "$SubscriptionName" | Select-AzureRmSubscription
Write-Output "Selected Azure Subscription"
# Find existing Resource Group:
$rg = Get-AzureRmResourceGroup -Name $RGName -ErrorAction Stop
# Get output params from both addons: keyvault and slots:
$keyvaultOutParams = (Get-AzureRmResourceGroupDeployment -ResourceGroupName $rg.ResourceGroupName -Name "sitecore-keyvault").Outputs
$slotsOutParams = (Get-AzureRmResourceGroupDeployment -ResourceGroupName $rg.ResourceGroupName -Name "sitecore-slots").Outputs
$WebAppName = $null
$SlotName = $null
# Fetch web site and slot
if($Role -eq "CM") {
$WebAppName = $keyvaultOutParams.cmWebAppNameTidy.Value
$SlotName = $slotsOutParams.cmSlotName.Value
}
if($Role -eq "CD") {
$WebAppName = $keyvaultOutParams.cdWebAppNameTidy.Value
$SlotName = $slotsOutParams.cdSlotName.Value
}
# Select Subscription:
Get-AzureRmSubscription -SubscriptionName "$SubscriptionName" | Select-AzureRmSubscription
Write-Output "Selected Azure Subscription"
if($DoNotDeleteExistingFiles){
& "$scriptDir\deploy-xm1-continuous-generic.ps1" -SubscriptionName $SubscriptionName -RGName $RGName -PackageLocation $PackageLocation -ParamsFileLocation $ParamsFileLocation -WebAppName $WebAppName -SlotName $SlotName -TempFolderName "$TempFolderName" -DoNotDeleteExistingFiles -SkipDbOperations:$SkipDbOperations
}
else{
& "$scriptDir\deploy-xm1-continuous-generic.ps1" -SubscriptionName $SubscriptionName -RGName $RGName -PackageLocation $PackageLocation -ParamsFileLocation $ParamsFileLocation -WebAppName $WebAppName -SlotName $SlotName -TempFolderName "$TempFolderName" -SkipDbOperations:$SkipDbOperations
}