-
Notifications
You must be signed in to change notification settings - Fork 1
/
install.ps1
105 lines (84 loc) · 4.18 KB
/
install.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
<#
.SYNOPSIS
Install the Full Infrastructure As Code Solution
.DESCRIPTION
This Script will install all the infrastructure needed for the solution.
1. Resource Group
.EXAMPLE
.\install.ps1
Version History
v1.0 - Initial Release
#>
#Requires -Version 5.1
#Requires -Module @{ModuleName='AzureRM.Resources'; ModuleVersion='5.0'}
param(
[boolean] $Prepare = $false,
[boolean] $Infrastructure = $false,
[boolean] $RBAC = $false,
[boolean] $Cluster = $false,
[Parameter(Mandatory = $true)] [string] $Environment,
[string] $ResourceGroupName = "$env:AZURE_RANDOM-$env:AZURE_GROUP",
[string] $Location = $env:AZURE_LOCATION,
[string] $Prefix = $env:AZURE_GROUP,
[string] $Random = $env:AZURE_RANDOM
)
# Clear any existing environment settings.
$Env:AZURE_TENANT = [string]::Empty
$Env:AZURE_SUBSCRIPTION = [string]::Empty
$Env:AZURE_PRINCIPAL = [string]::Empty
$Env:AZURE_LOCATION = [string]::Empty
$Env:AZURE_GROUP = [string]::Empty
$Env:AZURE_RANDOM = [string]::Empty
$Env:AZURE_USERNAME = [string]::Empty
$Env:AZURE_PASSWORD = [string]::Empty
$Env:AZURE_ANALYTICS = [string]::Empty
$Env:AZURE_ANALYTICS_KEY = [string]::Empty
$Env:FABRIC_TIER = [string]::Empty
$Env:FABRIC_NODE_COUNT = 0
$Env:CLUSTER_APP = [string]::Empty
$Env:CLIENT_APP = [string]::Empty
# Load Project Environment Settings and Functions
if (Test-Path "$PSScriptRoot\.env_$Environment.ps1") { . "$PSScriptRoot\.env_$Environment.ps1" }
if (Test-Path "$PSScriptRoot\infrastructure\functions.ps1") { . "$PSScriptRoot\infrastructure\functions.ps1" }
# Display Project Environment Settings
Get-ChildItem Env:AZURE*
Get-ChildItem Env:FABRIC*
if ($Prepare -eq $true) {
Write-Host "Preparing for Install here we go...." -ForegroundColor "cyan"
& ./infrastructure/iac-keyvault/install.ps1 -Prefix "sf$Random" -Environment $Environment
Write-Host "---------------------------------------------" -ForegroundColor "blue"
Write-Host "Preparation has been completed!!!!!" -ForegroundColor "red"
Write-Host "---------------------------------------------" -ForegroundColor "blue"
}
if ($RBAC -eq $true) {
$tenantId = (Get-AzureRmContext).Tenant.Id
$replyUrl = "https://sf$Random-$Environment.$Location.cloudapp.azure.com:19080/Explorer/index.html"
$clusterName = "sf$Random"
Write-Host "Enabling Active Directory RBAC here we go...." -ForegroundColor "cyan"
Write-Color " tenant: ", $tenantId -Color yellow, blue
Write-Color " replyUrl: ", $replyUrl -Color yellow, blue
Write-Color " cluster: ", $clusterName -Color yellow, blue
& ./infrastructure/aadtool/SetupApplications.ps1 -TenantId $tenantId -ClusterName $clusterName -WebApplicationReplyUrl $replyUrl
Write-Host "---------------------------------------------" -ForegroundColor "blue"
Write-Host "Active Directory RBAC has been installed!!!!!" -ForegroundColor "red"
Write-Host "---------------------------------------------" -ForegroundColor "blue"
}
if ($Infrastructure -eq $true) {
Write-Host "Install Infrastructure Resources here we go...." -ForegroundColor "cyan"
& ./infrastructure/iac-storage/install.ps1 -Prefix "sf$Random" -Environment $Environment
& ./infrastructure/iac-network/install.ps1 -Prefix "sf$Random" -Environment $Environment
& ./infrastructure/iac-publicLB/install.ps1 -Prefix "sf$Random" -Environment $Environment
& ./infrastructure/iac-logAnalytics/install.ps1 -Prefix "sf$Random" -Environment $Environment
Write-Host "---------------------------------------------" -ForegroundColor "blue"
Write-Host "Infrastructure Components have been installed!!!!!" -ForegroundColor "red"
Write-Host "---------------------------------------------" -ForegroundColor "blue"
}
if ($Cluster -eq $true) {
Write-Host "Install Cluster Resources here we go...." -ForegroundColor "cyan"
& ./infrastructure/iac-serviceFabric/install.ps1 -Prefix "sf$Random" -Environment $Environment
Write-Host "---------------------------------------------" -ForegroundColor "blue"
Write-Host "Cluster Components have been installed!!!!!" -ForegroundColor "red"
Write-Host "---------------------------------------------" -ForegroundColor "blue"
$env:Endpoint = "sf$Random.eastus2.cloudapp.azure.com:19000"
Write-Color -Text "Endpoint = ", $env:Endpoint -Color green, red
}