Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,4 @@ templates/.test_github
.vscode/settings.json
/ALZ
.tools
.cache
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ function Get-AcceleratorFolderConfiguration {
IacType = $null
VersionControl = $null
ConfigFolderPath = $null
OutputFolderPath = $null
InputsYamlPath = $null
InputsYaml = $null
InputsContent = $null
Expand All @@ -45,9 +46,11 @@ function Get-AcceleratorFolderConfiguration {
$result.FolderExists = $true

$configFolderPath = Join-Path $FolderPath "config"
$outputFolderPath = Join-Path $FolderPath "output"
$inputsYamlPath = Join-Path $configFolderPath "inputs.yaml"

$result.ConfigFolderPath = $configFolderPath
$result.OutputFolderPath = $outputFolderPath
$result.InputsYamlPath = $inputsYamlPath

# Check if config folder exists
Expand Down
51 changes: 50 additions & 1 deletion src/ALZ/Private/Deploy-Accelerator-Helpers/Get-AzureContext.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,52 @@ function Get-AzureContext {
that the currently logged-in user has access to. The results are returned as a hashtable
containing arrays for use in interactive selection prompts.
Only subscriptions from the current tenant are returned.
Results are cached locally for 1 hour to improve performance.
.PARAMETER OutputDirectory
The output directory where the .cache folder will be created for storing the cached Azure context.
.PARAMETER ClearCache
When set, clears the cached Azure context and fetches fresh data from Azure.
.OUTPUTS
Returns a hashtable with the following keys:
- ManagementGroups: Array of objects with id and displayName properties
- Subscriptions: Array of objects with id and name properties
- Regions: Array of objects with name, displayName, and hasAvailabilityZones properties
#>
[CmdletBinding()]
param()
param(
[Parameter(Mandatory = $true)]
[string]$OutputDirectory,

[Parameter(Mandatory = $false)]
[switch]$ClearCache
)

# Define cache file path and expiration time (1 hour)
$cacheFolder = Join-Path $OutputDirectory ".cache"
$cacheFilePath = Join-Path $cacheFolder "azure-context-cache.json"
$cacheExpirationHours = 24

# Clear cache if requested
if ($ClearCache.IsPresent -and (Test-Path $cacheFilePath)) {
Remove-Item -Path $cacheFilePath -Force
Write-InformationColored "Azure context cache cleared." -ForegroundColor Yellow -InformationAction Continue
}

# Check if valid cache exists
if (Test-Path $cacheFilePath) {
$cacheFile = Get-Item $cacheFilePath
$cacheAge = (Get-Date) - $cacheFile.LastWriteTime
if ($cacheAge.TotalHours -lt $cacheExpirationHours) {
try {
$cachedContext = Get-Content -Path $cacheFilePath -Raw | ConvertFrom-Json -AsHashtable
Write-InformationColored "Using cached Azure context (cached $([math]::Round($cacheAge.TotalMinutes)) minutes ago). Use -clearCache to refresh." -ForegroundColor Gray -InformationAction Continue
Write-InformationColored " Found $($cachedContext.ManagementGroups.Count) management groups, $($cachedContext.Subscriptions.Count) subscriptions, and $($cachedContext.Regions.Count) regions" -ForegroundColor Gray -InformationAction Continue
return $cachedContext
} catch {
Write-Verbose "Failed to read cache file, will fetch fresh data."
}
}
}

$azureContext = @{
ManagementGroups = @()
Expand Down Expand Up @@ -52,6 +90,17 @@ function Get-AzureContext {
}

Write-InformationColored " Found $($azureContext.ManagementGroups.Count) management groups, $($azureContext.Subscriptions.Count) subscriptions, and $($azureContext.Regions.Count) regions" -ForegroundColor Gray -InformationAction Continue

# Save to cache
try {
if (-not (Test-Path $cacheFolder)) {
New-Item -Path $cacheFolder -ItemType Directory -Force | Out-Null
}
$azureContext | ConvertTo-Json -Depth 10 | Set-Content -Path $cacheFilePath -Force
Write-Verbose "Azure context cached to $cacheFilePath"
} catch {
Write-Verbose "Failed to write cache file: $_"
}
} catch {
Write-InformationColored " Warning: Could not query Azure resources. You will need to enter IDs manually." -ForegroundColor Yellow -InformationAction Continue
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
function Get-ModuleVersionData {
[CmdletBinding()]
param (
[Parameter(Mandatory = $true)]
[string] $targetDirectory,

[Parameter(Mandatory = $true)]
[ValidateSet("bootstrap", "starter")]
[string] $moduleType
)

$dataFilePath = Join-Path $targetDirectory ".alz-version-data.json"

if (Test-Path $dataFilePath) {
$data = Get-Content $dataFilePath | ConvertFrom-Json
$versionKey = "$($moduleType)Version"
return $data.$versionKey
}

return $null
}
32 changes: 0 additions & 32 deletions src/ALZ/Private/Deploy-Accelerator-Helpers/Invoke-FullUpgrade.ps1

This file was deleted.

88 changes: 0 additions & 88 deletions src/ALZ/Private/Deploy-Accelerator-Helpers/Invoke-Upgrade.ps1

This file was deleted.

7 changes: 0 additions & 7 deletions src/ALZ/Private/Deploy-Accelerator-Helpers/New-Bootstrap.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,6 @@ function New-Bootstrap {

Write-Verbose "Bootstrap Module Path: $bootstrapModulePath"

# Run upgrade
Invoke-FullUpgrade `
-bootstrapModuleFolder $bootstrapDetails.Value.location `
-bootstrapRelease $bootstrapRelease `
-bootstrapPath $bootstrapTargetPath `
-autoApprove:$autoApprove.IsPresent

# Get starter module
$starterModulePath = ""
$starterRootModuleFolder = ""
Expand Down
Loading
Loading