Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit cb23b88

Browse filesBrowse files
committed
feat: requirements
1 parent f98ebaf commit cb23b88
Copy full SHA for cb23b88
Expand file treeCollapse file tree

12 files changed

+149
-622
lines changed

‎README.md

Copy file name to clipboardExpand all lines: README.md
+8-27Lines changed: 8 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -10,49 +10,30 @@
1010

1111
## Introduction
1212

13-
TLDR: Head straight over to our [Quick Start](https://github.com/Azure/ALZ-PowerShell-Module/wiki/%5BUser-Guide%5D-Quick-Start) to get going now.
14-
1513
This repository contains the PowerShell module and documentation for the Azure landing zones Accelerators for Bicep and Terraform. The accelerators are an opinionated implementation of the Azure Landing Zones Terraform modules, with Azure DevOps or GitHub bootstrapping.
1614

1715
It is designed to be used as a template to enable you to get started quickly deploying ALZ with Bicep or Terraform.
1816

19-
Please refer to our [Wiki](https://github.com/Azure/ALZ-PowerShell-Module/wiki) for detailed features and usage instructions.
17+
Please refer to our [Docs](https://aka.ms/alz/acc) for detailed features and usage instructions.
2018

2119
## Quick Start
2220

2321
To get going right now, run these PowerShell steps:
2422

2523
```pwsh
2624
Install-Module -Name ALZ
27-
Deploy-Accelerator
28-
```
29-
30-
## More Examples
31-
32-
Here are more examples with different options:
33-
34-
### Azure Landing Zone Environment with Bicep and GitHub Actions Workflows
35-
36-
```powershell
37-
Deploy-Accelerator -o <output_directory> -i "bicep" -b "alz_github"
25+
Deploy-Accelerator -inputs "inputs.yaml"
3826
```
3927

40-
### Azure Landing Zone Environment with Bicep and Azure DevOps Pipelines
28+
## Software Requirements
4129

42-
```powershell
43-
Deploy-Accelerator -o <output_directory> -i "bicep" -b "alz_azuredevops"
44-
```
45-
46-
### Azure Landing Zone Environment with Terraform and GitHub Pipelines
47-
48-
```powershell
49-
Deploy-Accelerator -o <output_directory> -i "terraform" -b "alz_github"
50-
```
30+
You can see the software requirements for the ALZ Accelerators in the [Phase 1 Docs](https://aka.ms/alz/acc/phase1).
5131

52-
### Azure Landing Zone Environment with Terraform and Azure DevOps Pipelines
32+
To check the requirements, run these commands:
5333

54-
```powershell
55-
Deploy-Accelerator -o <output_directory> -i "terraform" -b "alz_azuredevops"
34+
```pwsh
35+
Install-Module -Name ALZ
36+
Test-AcceleratorRequirements
5637
```
5738

5839
## Contributing

‎src/ALZ/ALZ.psd1

Copy file name to clipboardExpand all lines: src/ALZ/ALZ.psd1
+3-10Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,8 @@
7272

7373
# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
7474
FunctionsToExport = @(
75-
'New-ALZEnvironment'
76-
'Test-ALZRequirement'
77-
'Edit-LineEnding'
75+
'Test-AcceleratorRequirement',
76+
'Deploy-Accelerator'
7877
)
7978

8079
# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
@@ -84,10 +83,7 @@
8483
VariablesToExport = '*'
8584

8685
# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export.
87-
AliasesToExport = @(
88-
'Edit-LineEndings'
89-
'Deploy-Accelerator'
90-
)
86+
AliasesToExport = @()
9187

9288
# DSC resources to export from this module
9389
# DscResourcesToExport = @()
@@ -142,7 +138,4 @@
142138

143139
# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix.
144140
# DefaultCommandPrefix = ''
145-
146141
}
147-
148-
+111Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
function Test-Tooling {
2+
$checkResults = @()
3+
$hasFailure = $false
4+
5+
# Check if PowerShell is the correct version
6+
Write-Verbose "Checking PowerShell version"
7+
$powerShellVersionTable = $PSVersionTable
8+
$powerShellVersion = $powerShellVersionTable.PSVersion.ToString()
9+
if ($powerShellVersionTable.PSVersion.Major -lt 7) {
10+
$checkResults += @{
11+
message = "PowerShell version $powerShellVersion is not supported. Please upgrade to PowerShell 7.4 or higher. Either switch to the `pwsh` prompt or follow the instructions here: https://aka.ms/install-powershell"
12+
result = "Failure"
13+
}
14+
$hasFailure = $true
15+
} elseif ($powerShellVersionTable.PSVersion.Major -eq 7 -and $powerShellVersionTable.PSVersion.Minor -lt 4) {
16+
$checkResults += @{
17+
message = "PowerShell version $powerShellVersion is not supported. Please upgrade to PowerShell 7.4 or higher. Either switch to the `pwsh` prompt or follow the instructions here: https://aka.ms/install-powershell"
18+
result = "Failure"
19+
}
20+
$hasFailure = $true
21+
} else {
22+
$checkResults += @{
23+
message = "PowerShell version $powerShellVersion is supported."
24+
result = "Success"
25+
}
26+
}
27+
28+
# Check if Git is installed
29+
Write-Verbose "Checking Git installation"
30+
$gitPath = Get-Command git -ErrorAction SilentlyContinue
31+
if ($gitPath) {
32+
$checkResults += @{
33+
message = "Git is installed."
34+
result = "Success"
35+
}
36+
} else {
37+
$checkResults += @{
38+
message = "Git is not installed. Follow the instructions here: https://git-scm.com/downloads"
39+
result = "Failure"
40+
}
41+
$hasFailure = $true
42+
}
43+
44+
# Check if Azure CLI is installed
45+
Write-Verbose "Checking Azure CLI installation"
46+
$azCliPath = Get-Command az -ErrorAction SilentlyContinue
47+
if ($azCliPath) {
48+
$checkResults += @{
49+
message = "Azure CLI is installed."
50+
result = "Success"
51+
}
52+
} else {
53+
$checkResults += @{
54+
message = "Azure CLI is not installed. Follow the instructions here: https://learn.microsoft.com/en-us/cli/azure/install-azure-cli"
55+
result = "Failure"
56+
}
57+
$hasFailure = $true
58+
}
59+
60+
# Check if Azure CLI is logged in
61+
Write-Verbose "Checking Azure CLI login status"
62+
$azCliAccount = $(az account show -o json) | ConvertFrom-Json
63+
if ($azCliAccount) {
64+
$checkResults += @{
65+
message = "Azure CLI is logged in. Tenant ID: $($azCliAccount.tenantId), Subscription: $($azCliAccount.name) ($($azCliAccount.id))"
66+
result = "Success"
67+
}
68+
} else {
69+
$checkResults += @{
70+
message = "Azure CLI is not logged in. Please login to Azure CLI using 'az login -t `"00000000-0000-0000-0000-000000000000}`"', replacing the empty GUID with your tenant ID."
71+
result = "Failure"
72+
}
73+
$hasFailure = $true
74+
}
75+
76+
# Check if latest ALZ module is installed
77+
Write-Verbose "Checking ALZ module version"
78+
$alzModuleCurrentVersion = Get-InstalledModule -Name ALZ
79+
$alzModuleLatestVersion = Find-Module -Name ALZ
80+
if ($alzModuleCurrentVersion.Version -lt $alzModuleLatestVersion.Version) {
81+
$checkResults += @{
82+
message = "ALZ module is not the latest version. Your version: $($alzModuleCurrentVersion.Version), Latest version: $($alzModuleLatestVersion.Version). Please update to the latest version using 'Update-Module ALZ'."
83+
result = "Failure"
84+
}
85+
$hasFailure = $true
86+
} else {
87+
$checkResults += @{
88+
message = "ALZ module is the latest version ($($alzModuleCurrentVersion.Version))."
89+
result = "Success"
90+
}
91+
}
92+
93+
Write-Verbose "Showing check results"
94+
$checkResults | ForEach-Object {[PSCustomObject]$_} | Format-Table -Property @{
95+
Label = "Check Result"; Expression = {
96+
switch ($_.result) {
97+
'Success' { $color = "92"; break }
98+
'Failure' { $color = "91"; break }
99+
default { $color = "0" }
100+
}
101+
$e = [char]27
102+
"$e[${color}m$($_.result)${e}[0m"
103+
}
104+
}, @{ Label = "Check Details"; Expression = {$_.message} } -AutoSize -Wrap
105+
106+
if($hasFailure) {
107+
Write-InformationColored "Accelerator software requirements have no been met, please review and install the missing software." -ForegroundColor Red -InformationAction Continue
108+
Write-InformationColored "Cannot continue with Deployment..." -ForegroundColor Red -InformationAction Continue
109+
throw "Accelerator software requirements have no been met, please review and install the missing software."
110+
}
111+
}

‎src/ALZ/Public/New-ALZEnvironment.ps1 renamed to ‎src/ALZ/Public/Deploy-Accelerator.ps1

Copy file name to clipboardExpand all lines: src/ALZ/Public/Deploy-Accelerator.ps1
+4-3Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function New-ALZEnvironment {
1+
function Deploy-Accelerator {
22
<#
33
.SYNOPSIS
44
Deploys an accelerator according to the supplied inputs.
@@ -174,6 +174,9 @@ function New-ALZEnvironment {
174174

175175
$ProgressPreference = "SilentlyContinue"
176176

177+
Write-InformationColored "Checking the software requirements for the Accelerator..." -ForegroundColor Green -InformationAction Continue
178+
Test-Tooling
179+
177180
Write-InformationColored "Getting ready to deploy the accelerator with you..." -ForegroundColor Green -InformationAction Continue
178181

179182
if ($PSCmdlet.ShouldProcess("Accelerator setup", "modify")) {
@@ -366,5 +369,3 @@ function New-ALZEnvironment {
366369

367370
return
368371
}
369-
370-
New-Alias -Name "Deploy-Accelerator" -Value "New-ALZEnvironment"

‎src/ALZ/Public/Edit-LineEnding.ps1

Copy file name to clipboardExpand all lines: src/ALZ/Public/Edit-LineEnding.ps1
-43Lines changed: 0 additions & 43 deletions
This file was deleted.

‎src/ALZ/Public/Test-ALZRequirement.ps1

Copy file name to clipboardExpand all lines: src/ALZ/Public/Test-ALZRequirement.ps1
-97Lines changed: 0 additions & 97 deletions
This file was deleted.
+20Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
function Test-AcceleratorRequirement {
2+
<#
3+
.SYNOPSIS
4+
Test that the Accelerator software requirements are met
5+
.DESCRIPTION
6+
This will check for the pre-requisite software
7+
.EXAMPLE
8+
C:\PS> Test-AcceleratorRequirement
9+
.EXAMPLE
10+
C:\PS> Test-AcceleratorRequirement -Verbose
11+
.OUTPUTS
12+
Boolean - True if all requirements are met, false if not.
13+
.NOTES
14+
This function is used by the Deploy-Accelerator function to ensure that the software requirements are met before attempting run the Accelerator.
15+
.COMPONENT
16+
ALZ
17+
#>
18+
19+
Test-Tooling
20+
}

‎src/PSScriptAnalyzerSettings.psd1

Copy file name to clipboardExpand all lines: src/PSScriptAnalyzerSettings.psd1
-5Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,4 @@
5858
# }
5959
#}
6060
#________________________________________
61-
'Rules' = @{
62-
'PSAvoidUsingCmdletAliases' = @{
63-
'allowlist' = @('Edit-LineEndings','Deploy-Accelerator')
64-
}
65-
}
6661
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.