-
Notifications
You must be signed in to change notification settings - Fork 8
/
sitecore9.xp0.azure.ps1
331 lines (287 loc) · 7.47 KB
/
sitecore9.xp0.azure.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
#requires -RunAsAdministrator
#requires -Version 5.1
#requires -module Azure
#requires -module AzureRm.Profile
#requires -module AzureRm.Storage
#requires -module AzureRm.KeyVault
#requires -module SitecoreInstallExtensions
#requires -module SitecoreInstallAzure
# To be sure that proper version of SIF is used
Remove-Module SitecoreInstallFramework
Import-Module SitecoreInstallFramework -RequiredVersion 1.2.1
If(![Environment]::Is64BitProcess)
{
Write-Host "Please run 64-bit PowerShell" -foregroundcolor "yellow"
return
}
#region Steps implementation
class Steps
{
[string] $Path
$Steps = @()
Steps ([string] $path)
{
$this.Path = $path -replace "ps1","steps.json"
if( (Test-Path $this.Path) )
{
$this.Steps = (Get-Content -Path $this.Path -Raw) | ConvertFrom-Json
}
else
{
$this.Steps = @()
}
}
# mark step as executed
Executed([string] $stepName)
{
$this.Steps += $stepName
$json = ConvertTo-Json -InputObject $this.Steps
Set-Content -Path $this.Path -Value $json
}
[bool] IsNotExecuted([string] $stepName)
{
return -not ($this.Steps.Contains($stepName))
}
}
#endregion
#region "Parameters"
$LocalStorage = "$PSScriptRoot\Storage"
$GitHubRoot = "https://raw.githubusercontent.com/SoftServeInc/SitecoreInstallExtensions/master/Configuration/"
# Prefix is used for Sitecore website, xConnect website and database
$prefix = "sc9u2"
$sitecoreSiteName = "$prefix.local"
$XConnectCollectionService = "$prefix.xconnect"
#for Solr installation
$SolrHost = "solr.local"
$SolrPort = "8983"
# internally in 'solr.json', installation path is build like $SolrInstallFolder\solr-parameter('SolrVersion')
$SolrInstallFolder = "C:\solr"
$SolrService = "PSSolrService"
# for Solr cores configuration
$SolrRoot = "$SolrInstallFolder\solr-6.6.2"
$SolrUrl = "https://$($SolrHost):$($SolrPort)/solr"
$SqlServer = "$env:computername" #OR "SQLServerName\SQLInstanceName"
$SqlAdminUser = ""
# for password use '' not ""
$SqlAdminPassword= ''
$AzureSubscription = ""
$AzureResourceGroup = ""
$AzureStorageName = ""
# Choose version for download
$SitecoreVersion = "9.0.2"
#endregion
###################################################################################
#
# Always read and configure parameters in section above
#
###################################################################################
# For Windows Server $Workstation must be set to $false, for Windows 8/10/Next to $true
$Workstation = !((gwmi win32_operatingsystem).caption -split " " -contains "Server")
# Do not display progress (performance improvement)
$global:ProgressPreference = 'silentlyContinue'
# initialize steps functionality
$steps = [Steps]::new($MyInvocation.MyCommand.Source)
#region "Download Artifacts"
Invoke-WebRequest -Uri "$GitHubRoot/sitecore9.azure.json" -OutFile "$PSScriptRoot\sitecore9.azure.json"
$downloadSitecorePrerequisites = @{
Path = "$PSScriptRoot\sitecore9.azure.json"
Destination = $LocalStorage
SubscriptionName = $AzureSubscription
ResourceGroupName = $AzureResourceGroup
StorageName = $AzureStorageName
SitecoreVersion = $SitecoreVersion
}
try
{
if( $AzureSubscription -ne $null -and $AzureResourceGroup -ne $null )
{
if( $steps.IsNotExecuted("downloadSitecorePrerequisites") )
{
Install-SitecoreConfiguration @downloadSitecorePrerequisites
$steps.Executed("downloadSitecorePrerequisites")
}
}
}
catch
{
throw
}
#endregion
#region "Install Prerequisites"
Invoke-WebRequest -Uri "$GitHubRoot/sitecore9.prerequisites.json" -OutFile "$PSScriptRoot\sitecore9.prerequisites.json"
$prerequisites = @{
Path = "$PSScriptRoot\sitecore9.prerequisites.json"
LocalStorage = $LocalStorage
SqlServer = $SqlServer
SqlAdminUser = $SqlAdminUser
SqlAdminPassword = $SqlAdminPassword
Workstation = $Workstation
}
try
{
if( $steps.IsNotExecuted("installPrerequisites") )
{
Install-SitecoreConfiguration @prerequisites
$steps.Executed("installPrerequisites")
}
}
catch
{
throw
}
#endregion
#region "Install Solr with SSL"
Invoke-WebRequest -Uri "$GitHubRoot/Solr.json" -OutFile "$PSScriptRoot\Solr.json"
$installSolr =@{
Path = "$PSScriptRoot\Solr.json"
LocalStorage = "$LocalStorage"
SolrHost = $SolrHost
SolrPort = $SolrPort
SolrServiceName = $SolrService
InstallFolder = "$SolrInstallFolder"
# For SSL certificate generation
CertPassword = "secret"
CertStoreLocation = "Cert:\LocalMachine\My"
CertificateName = $SolrHost
Property = "Subject"
Value = "CN=$SolrHost"
# if you want to download JRE and Solr check JREDownloadUrl and SolrDownloadUrl in solr.json
# and switch to $false
UseLocalFiles = $true
}
try
{
if( $steps.IsNotExecuted("installSolr") )
{
Install-SitecoreConfiguration @installSolr
$steps.Executed("installSolr")
}
}
catch
{
throw
}
#endregion
#region "Step-CreateCert"
#install client certificate for xconnect
$certParams = @{
Path = "$LocalStorage\xconnect-createcert.json"
CertificateName = "$prefix.xconnect_client"
}
try
{
if( $steps.IsNotExecuted("certParams") )
{
Install-SitecoreConfiguration @certParams
$steps.Executed("certParams")
}
}
catch
{
throw
}
#endregion
#region "Step-Solr-XConnect"
#install solr cores for xdb
$solrParams = @{
Path = "$LocalStorage\xconnect-solr.json"
SolrUrl = $SolrUrl
SolrRoot = $SolrRoot
SolrService = $SolrService
CorePrefix = $prefix
}
try
{
if( $steps.IsNotExecuted("solrParams") )
{
Install-SitecoreConfiguration @solrParams
$steps.Executed("solrParams")
}
}
catch
{
throw
}
#endregion
#region "Step-XConnect-Web"
#deploy xconnect instance
$xconnectParams = @{
Path = "$LocalStorage\xconnect-xp0.json"
Package = "$LocalStorage\Sitecore * (OnPrem)_xp0xconnect.scwdp.zip"
LicenseFile = "$LocalStorage\license.xml"
Sitename = $XConnectCollectionService
XConnectCert = $certParams.CertificateName
SqlDbPrefix = $prefix
SqlServer = $SqlServer
SqlAdminUser = $SqlAdminUser
SqlAdminPassword = $SqlAdminPassword
SolrCorePrefix = $prefix
SolrURL = $SolrUrl
}
try
{
if( $steps.IsNotExecuted("xconnectParams") )
{
Install-SitecoreConfiguration @xconnectParams
$steps.Executed("xconnectParams")
}
}
catch
{
throw
}
#endregion
#region "Step-Solr-Sitecore"
#install solr cores for sitecore
$sitecoreSolrParams = @{
Path = "$LocalStorage\sitecore-solr.json"
SolrUrl = $SolrUrl
SolrRoot = $SolrRoot
SolrService = $SolrService
CorePrefix = $prefix
}
try
{
if( $steps.IsNotExecuted("sitecoreSolrParams") )
{
Install-SitecoreConfiguration @sitecoreSolrParams
$steps.Executed("sitecoreSolrParams")
}
}
catch
{
throw
}
#endregion
#region "Step-Sitecore"
#install sitecore instance
$sitecoreParams = @{
Path = "$LocalStorage\sitecore-XP0.json"
Package = "$LocalStorage\Sitecore * (OnPrem)_single.scwdp.zip"
LicenseFile = "$LocalStorage\license.xml"
SqlDbPrefix = $prefix
SqlServer = $SqlServer
SqlAdminUser = $SqlAdminUser
SqlAdminPassword = $SqlAdminPassword
SolrCorePrefix = $prefix
SolrUrl = $SolrUrl
XConnectCert = $certParams.CertificateName
Sitename = $sitecoreSiteName
XConnectCollectionService = "https://$XConnectCollectionService"
}
try
{
if( $steps.IsNotExecuted("sitecoreParams") )
{
Install-SitecoreConfiguration @sitecoreParams
$steps.Executed("sitecoreParams")
}
}
catch
{
throw
}
#endregion
Start-Process $SolrUrl
Start-Process "http://$sitecoreSiteName"
Start-Process "https://$XConnectCollectionService"