Skip to content

Commit 18070ae

Browse files
authored
PERF-334 Azure Migration for Performance Testing (#112)
* azurerm provider version updated * module for scripts installation added * configration section for vms added * scripts for installing pre-requisites added * http and https configuration added * azurerm version updated * shut down configuration added and storage account type updated * azurerm version updated * outputs updated to get the script extension id * vms sizes and images updated
1 parent 462ca13 commit 18070ae

17 files changed

+562
-42
lines changed

eng/terraform/.terraform.lock.hcl

Lines changed: 27 additions & 27 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
# Licensed to the Ed-Fi Alliance under one or more agreements.
3+
# The Ed-Fi Alliance licenses this file to you under the Apache License, Version 2.0.
4+
# See the LICENSE and NOTICES files in the project root for more information.
5+
function Install-PowerShellTools {
6+
[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12
7+
Install-PackageProvider -Name NuGet -Force
8+
Install-Module SqlServer -AllowClobber -Force
9+
}
10+
####### Tools-Helper.psm1
11+
function Invoke-RefreshPath {
12+
# Some of the installs in this process do not set the immediate path correctly.
13+
# This function simply reads the global path settings and reloads them. Useful
14+
# when you can't even get to chocolatey's `refreshenv` command.
15+
16+
$env:Path=(
17+
[System.Environment]::GetEnvironmentVariable("Path","Machine"),
18+
[System.Environment]::GetEnvironmentVariable("Path","User")
19+
) -match '.' -join ';'
20+
}
21+
22+
function Test-ExitCode {
23+
if ($LASTEXITCODE -ne 0) {
24+
25+
throw @"
26+
The last task failed with exit code $LASTEXITCODE
27+
$(Get-PSCallStack)
28+
"@
29+
}
30+
}
31+
####### Configure-Windows.psm1
32+
function Set-TLS12Support {
33+
Write-Host "Enabling TLS 1.2"
34+
35+
if (-not [Net.ServicePointManager]::SecurityProtocol.HasFlag([Net.SecurityProtocolType]::Tls12)) {
36+
[Net.ServicePointManager]::SecurityProtocol += [Net.SecurityProtocolType]::Tls12
37+
}
38+
}
39+
40+
function Enable-LongFileNames {
41+
Write-Host "Enabling long file name support"
42+
43+
if (Test-Path 'HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem') {
44+
Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem' -name "LongPathsEnabled" -Value 1 -Verbose -Force
45+
}
46+
}
47+
###### Install-Applications.psm1
48+
$common_args = @(
49+
"--execution-timeout=$installTimeout",
50+
"-y",
51+
"--ignore-pending-reboot"
52+
)
53+
54+
$installTimeout = 14400 # Set to 0 for infinite
55+
56+
function Install-Choco {
57+
if (Get-Command "choco.exe" -ErrorAction SilentlyContinue) {
58+
Write-Output "Chocolatey is already installed. Setting choco command."
59+
}
60+
else {
61+
Write-Output "Installing Chocolatey..."
62+
$uri = "https://chocolatey.org/install.ps1"
63+
Invoke-Expression ((New-Object System.Net.WebClient).DownloadString($uri))
64+
65+
&refreshenv
66+
}
67+
&choco feature disable --name showDownloadProgress --execution-timeout=$installTimeout
68+
Test-ExitCode
69+
70+
return Get-Command "choco.exe" -ErrorAction SilentlyContinue
71+
}
72+
function Install-DotNet {
73+
[CmdletBinding()]
74+
param (
75+
[Parameter(Mandatory=$True)]
76+
[string]
77+
$LogFile
78+
)
79+
Start-Transcript -Path $LogFile -Append
80+
&choco install dotnet-8.0-sdk @common_args
81+
Stop-Transcript
82+
Restart-Computer -Force
83+
}
84+
###### Run
85+
Set-NetFirewallProfile -Enabled False
86+
$ConfirmPreference="high"
87+
$ErrorActionPreference = "Stop"
88+
Set-TLS12Support
89+
Invoke-RefreshPath
90+
Enable-LongFileNames
91+
Install-Choco
92+
Install-PowerShellTools
93+
$applicationSetupLog = "$PSScriptRoot/application-setup.log"
94+
Install-DotNet -LogFile $applicationSetupLog
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
# Licensed to the Ed-Fi Alliance under one or more agreements.
3+
# The Ed-Fi Alliance licenses this file to you under the Apache License, Version 2.0.
4+
# See the LICENSE and NOTICES files in the project root for more information.
5+
function Add-Path {
6+
param(
7+
[Parameter(Mandatory, Position=0)]
8+
[string] $LiteralPath,
9+
[ValidateSet('User', 'CurrentUser', 'Machine', 'LocalMachine')]
10+
[string] $Scope
11+
)
12+
Set-StrictMode -Version 1; $ErrorActionPreference = 'Stop'
13+
$isMachineLevel = $Scope -in 'Machine', 'LocalMachine'
14+
if ($isMachineLevel -and -not $($ErrorActionPreference = 'Continue'; net session 2>$null)) { throw "You must run AS ADMIN to update the machine-level Path environment variable." }
15+
$regPath = 'registry::' + ('HKEY_CURRENT_USER\Environment', 'HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment')[$isMachineLevel]
16+
$currDirs = (Get-Item -LiteralPath $regPath).GetValue('Path', '', 'DoNotExpandEnvironmentNames') -split ';' -ne ''
17+
if ($LiteralPath -in $currDirs) {
18+
Write-Verbose "Already present in the persistent $(('user', 'machine')[$isMachineLevel])-level Path: $LiteralPath"
19+
return
20+
}
21+
$newValue = ($currDirs + $LiteralPath) -join ';'
22+
Set-ItemProperty -Type ExpandString -LiteralPath $regPath Path $newValue
23+
$dummyName = [guid]::NewGuid().ToString()
24+
[Environment]::SetEnvironmentVariable($dummyName, 'foo', 'User')
25+
[Environment]::SetEnvironmentVariable($dummyName, [NullString]::value, 'User')
26+
$env:Path = ($env:Path -replace ';$') + ';' + $LiteralPath
27+
Write-Verbose "`"$LiteralPath`" successfully appended to the persistent $(('user', 'machine')[$isMachineLevel])-level Path and also the current-process value."
28+
}
29+
function Test-ExitCode {
30+
if ($LASTEXITCODE -ne 0) {
31+
throw @"
32+
The last task failed with exit code $LASTEXITCODE
33+
$(Get-PSCallStack)
34+
"@
35+
}
36+
}
37+
####### Configure-Windows.psm1
38+
function Set-TLS12Support {
39+
Write-Host "Enabling TLS 1.2"
40+
41+
if (-not [Net.ServicePointManager]::SecurityProtocol.HasFlag([Net.SecurityProtocolType]::Tls12)) {
42+
[Net.ServicePointManager]::SecurityProtocol += [Net.SecurityProtocolType]::Tls12
43+
}
44+
}
45+
function Invoke-RefreshPath {
46+
# Some of the installs in this process do not set the immediate path correctly.
47+
# This function simply reads the global path settings and reloads them. Useful
48+
# when you can't even get to chocolatey's `refreshenv` command.
49+
$env:Path=(
50+
[System.Environment]::GetEnvironmentVariable("Path","Machine"),
51+
[System.Environment]::GetEnvironmentVariable("Path","User")
52+
) -match '.' -join ';'
53+
}
54+
function Enable-LongFileNames {
55+
Write-Host "Enabling long file name support"
56+
if (Test-Path 'HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem') {
57+
Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem' -name "LongPathsEnabled" -Value 1 -Verbose -Force
58+
}
59+
}
60+
function Install-PowerShellTools {
61+
[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12
62+
Install-PackageProvider -Name NuGet -Force
63+
Install-Module CredentialManager -AllowClobber -Force
64+
Install-Module SqlServer -AllowClobber -Force
65+
}
66+
function Update-Path {
67+
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") +
68+
";" +
69+
[System.Environment]::GetEnvironmentVariable("Path","User")
70+
}
71+
###### Install-Applications.psm1
72+
$common_args = @(
73+
"--execution-timeout=$installTimeout",
74+
"-y",
75+
"--ignore-pending-reboot"
76+
)
77+
$installTimeout = 14400 # Set to 0 for infinite
78+
function Install-Chocolatey {
79+
if (! (Get-Command choco.exe -ErrorAction SilentlyContinue )) {
80+
Set-ExecutionPolicy Bypass -Scope Process -Force
81+
Invoke-WebRequest https://chocolatey.org/install.ps1 -UseBasicParsing | Invoke-Expression
82+
$env:ChocolateyInstall = Convert-Path "$((Get-Command choco).path)\..\.."
83+
Import-Module "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1"
84+
refreshenv
85+
}
86+
}
87+
function Install-Pyenv {
88+
#$pyenvVersion = cmd /c pyenv --version
89+
if(!(Test-Path "C:\.pyenv\pyenv-win\bin")){
90+
&choco install pyenv-win @common_args
91+
refreshenv
92+
# refreshenv doesn't appear to be sufficient to recognize user environment variable changes
93+
Update-Path
94+
Copy-Item "C:\Windows\System32\config\systemprofile\.pyenv" "C:\.pyenv" -Recurse
95+
Add-Path "C:\.pyenv\pyenv-win\bin" -Scope Machine
96+
Add-Path "C:\.pyenv\pyenv-win\shims" -Scope Machine
97+
}
98+
}
99+
function Install-Python {
100+
pyenv install 3.9.4
101+
pyenv rehash
102+
pyenv local 3.9.4
103+
pyenv global 3.9.4
104+
}
105+
function Install-Poetry {
106+
# Ensure pip is on the latest version
107+
python -m pip install --upgrade pip
108+
# Update local and global PATH variables
109+
$addition = "C:\.pyenv\pyenv-win\versions\3.9.4\Scripts"
110+
Add-Path $addition -Scope Machine
111+
refreshenv
112+
# Install poetry
113+
# Poetry's native installation process encounters SSL errors
114+
# in some environments. `pip install` is a reasonable alternative
115+
# that has been shown to work in our situation.
116+
pip install poetry
117+
}
118+
Set-NetFirewallProfile -Enabled False
119+
$ConfirmPreference="high"
120+
$ErrorActionPreference = "Stop"
121+
Set-TLS12Support
122+
Invoke-RefreshPath
123+
Enable-LongFileNames
124+
Install-PowerShellTools
125+
Install-Chocolatey
126+
Install-Pyenv
127+
Invoke-RefreshPath
128+
Install-Python
129+
Install-Poetry

0 commit comments

Comments
 (0)