From dce2b21f0ad398deea11ba04912079ebe720aa40 Mon Sep 17 00:00:00 2001 From: Erik Bershel <110455084+erik-bershel@users.noreply.github.com> Date: Fri, 9 Jan 2026 11:03:49 +0100 Subject: [PATCH] [Ubuntu, Windows] Add Azure modules to PS scope; deprecate zip (#13482) --- .../build/Install-PowerShellAzModules.ps1 | 6 +++++- .../scripts/docs-gen/SoftwareReport.Common.psm1 | 5 ----- .../scripts/tests/PowerShellModules.Tests.ps1 | 9 --------- .../build/Install-PowershellAzModules.ps1 | 14 -------------- .../scripts/docs-gen/SoftwareReport.Common.psm1 | 17 +---------------- .../scripts/tests/PowerShellAzModules.Tests.ps1 | 8 -------- images/windows/toolsets/toolset-2019.json | 2 -- images/windows/toolsets/toolset-2022.json | 3 --- images/windows/toolsets/toolset-2025.json | 3 +-- 9 files changed, 7 insertions(+), 60 deletions(-) diff --git a/images/ubuntu/scripts/build/Install-PowerShellAzModules.ps1 b/images/ubuntu/scripts/build/Install-PowerShellAzModules.ps1 index 626dc2f70..b3dba5584 100644 --- a/images/ubuntu/scripts/build/Install-PowerShellAzModules.ps1 +++ b/images/ubuntu/scripts/build/Install-PowerShellAzModules.ps1 @@ -11,6 +11,7 @@ Import-Module "$env:HELPER_SCRIPTS/../tests/Helpers.psm1" # Get modules content from toolset $modules = (Get-ToolsetContent).azureModules $installPSModulePath = "/usr/share" +$psModuleMachinePath = $env:PSModulePath + ":" foreach ($module in $modules) { $moduleName = $module.name @@ -19,9 +20,12 @@ foreach ($module in $modules) { foreach ($version in $module.versions) { $modulePath = Join-Path -Path $installPSModulePath -ChildPath "${moduleName}_${version}" Write-Host " - $version [$modulePath]" + $psModuleMachinePath += ($modulePath + ":") Save-Module -Path $modulePath -Name $moduleName -RequiredVersion $version -Force } - } +$finalLine = "PSModulePath=$($psModuleMachinePath.TrimEnd(':').Replace("\root", '$HOME'))" +Add-Content -Path "/etc/environment" -Value $finalLine + Invoke-PesterTests -TestFile "PowerShellModules" -TestName "AzureModules" diff --git a/images/ubuntu/scripts/docs-gen/SoftwareReport.Common.psm1 b/images/ubuntu/scripts/docs-gen/SoftwareReport.Common.psm1 index d4ebbebb5..7d94facdc 100644 --- a/images/ubuntu/scripts/docs-gen/SoftwareReport.Common.psm1 +++ b/images/ubuntu/scripts/docs-gen/SoftwareReport.Common.psm1 @@ -266,11 +266,6 @@ function Get-PowerShellModules { $result += [ToolVersionsListNode]::new("Az", $azureInstalledModules, "^\d+\.\d+", "Inline") } - [Array] $azureCachedModules = Get-ChildItem /usr/share/az_*.zip -File | ForEach-Object { $_.Name.Split("_")[1] } - if ($azureCachedModules.Count -gt 0) { - $result += [ToolVersionsListNode]::new("Az (Cached)", $azureCachedModules, "^\d+\.\d+", "Inline") - } - (Get-ToolsetContent).powershellModules.name | ForEach-Object { $moduleName = $_ $moduleVersions = Get-Module -Name $moduleName -ListAvailable | Select-Object -ExpandProperty Version | Sort-Object -Unique diff --git a/images/ubuntu/scripts/tests/PowerShellModules.Tests.ps1 b/images/ubuntu/scripts/tests/PowerShellModules.Tests.ps1 index 9a1079ece..bf1cd9466 100644 --- a/images/ubuntu/scripts/tests/PowerShellModules.Tests.ps1 +++ b/images/ubuntu/scripts/tests/PowerShellModules.Tests.ps1 @@ -50,15 +50,6 @@ Describe "AzureModules" { $moduleVersion | Should -Match $expectedVersion } } - - if ($module.default) { - $moduleInfo = @{ moduleName = $moduleName; moduleDefault = $module.default } - - It " set as default" -TestCases $moduleInfo { - $moduleVersion = (Get-Module -ListAvailable -Name $moduleName).Version.ToString() - $moduleVersion | Should -Match $moduleDefault - } - } } } } diff --git a/images/windows/scripts/build/Install-PowershellAzModules.ps1 b/images/windows/scripts/build/Install-PowershellAzModules.ps1 index 2143fe111..71864c287 100644 --- a/images/windows/scripts/build/Install-PowershellAzModules.ps1 +++ b/images/windows/scripts/build/Install-PowershellAzModules.ps1 @@ -26,20 +26,6 @@ foreach ($module in $modules) { $psModuleMachinePath += "$modulePath;" Save-Module -Path $modulePath -Name $moduleName -RequiredVersion $version -Force -ErrorAction Stop } - - foreach ($version in $module.zip_versions) { - $modulePath = Join-Path -Path $installPSModulePath -ChildPath "${moduleName}_${version}" - Save-Module -Path $modulePath -Name $moduleName -RequiredVersion $version -Force -ErrorAction Stop - Compress-Archive -Path $modulePath -DestinationPath "${modulePath}.zip" - Remove-Item $modulePath -Recurse -Force - } - # Append default tool version to machine path - if ($null -ne $module.default) { - $defaultVersion = $module.default - - Write-Host "Use ${moduleName} ${defaultVersion} as default version..." - $psModuleMachinePath += "${installPSModulePath}\${moduleName}_${defaultVersion};" - } } # Add modules to the PSModulePath diff --git a/images/windows/scripts/docs-gen/SoftwareReport.Common.psm1 b/images/windows/scripts/docs-gen/SoftwareReport.Common.psm1 index d86440094..48cb75759 100644 --- a/images/windows/scripts/docs-gen/SoftwareReport.Common.psm1 +++ b/images/windows/scripts/docs-gen/SoftwareReport.Common.psm1 @@ -213,7 +213,7 @@ function Get-DotnetFrameworkVersions { function Get-PowerShellAzureModules { [Array] $result = @() - $defaultAzureModuleVersion = "2.1.0" + $defaultAzureModuleVersion = "12.5.0" [Array] $azInstalledModules = Get-ChildItem -Path "C:\Modules\az_*" -Directory | ForEach-Object { $_.Name.Split("_")[1] } if ($azInstalledModules.Count -gt 0) { @@ -230,21 +230,6 @@ function Get-PowerShellAzureModules { $result += [ToolVersionsListNode]::new("AzureRM", $($azurermInstalledModules), '^\d+\.\d+', "Inline") } - [Array] $azCachedModules = Get-ChildItem -Path "C:\Modules\az_*.zip" -File | ForEach-Object { $_.Name.Split("_")[1] } - if ($azCachedModules.Count -gt 0) { - $result += [ToolVersionsListNode]::new("Az (Cached)", $($azCachedModules), '^\d+\.\d+', "Inline") - } - - [Array] $azureCachedModules = Get-ChildItem -Path "C:\Modules\azure_*.zip" -File | ForEach-Object { $_.Name.Split("_")[1] } - if ($azureCachedModules.Count -gt 0) { - $result += [ToolVersionsListNode]::new("Azure (Cached)", $($azureCachedModules), '^\d+\.\d+', "Inline") - } - - [Array] $azurermCachedModules = Get-ChildItem -Path "C:\Modules\azurerm_*.zip" -File | ForEach-Object { $_.Name.Split("_")[1] } - if ($azurermCachedModules.Count -gt 0) { - $result += [ToolVersionsListNode]::new("AzureRM (Cached)", $($azurermCachedModules), '^\d+\.\d+', "Inline") - } - return $result } diff --git a/images/windows/scripts/tests/PowerShellAzModules.Tests.ps1 b/images/windows/scripts/tests/PowerShellAzModules.Tests.ps1 index 0fea778f3..920ed4fee 100644 --- a/images/windows/scripts/tests/PowerShellAzModules.Tests.ps1 +++ b/images/windows/scripts/tests/PowerShellAzModules.Tests.ps1 @@ -27,14 +27,6 @@ Describe "AzureModules" { $moduleVersion | Should -Match $expectedVersion } } - - if ($module.default) { - $moduleInfo = @{ moduleName = $moduleName; moduleDefault = $module.default } - It " set as default" -TestCases $moduleInfo { - $moduleVersions = Get-Module -ListAvailable -Name $moduleName | ForEach-Object { $_.Version.ToString() } - $moduleVersions | Should -Contain $moduleDefault - } - } } } } diff --git a/images/windows/toolsets/toolset-2019.json b/images/windows/toolsets/toolset-2019.json index 257a2dff7..581eb94a4 100644 --- a/images/windows/toolsets/toolset-2019.json +++ b/images/windows/toolsets/toolset-2019.json @@ -94,8 +94,6 @@ "name": "az", "versions": [ "12.5.0" - ], - "zip_versions": [ ] } ], diff --git a/images/windows/toolsets/toolset-2022.json b/images/windows/toolsets/toolset-2022.json index e25a65548..451e64252 100644 --- a/images/windows/toolsets/toolset-2022.json +++ b/images/windows/toolsets/toolset-2022.json @@ -91,9 +91,6 @@ "name": "az", "versions": [ "12.5.0" - ], - "zip_versions": [ - ] } ], diff --git a/images/windows/toolsets/toolset-2025.json b/images/windows/toolsets/toolset-2025.json index 7f003bab3..c81d68b92 100644 --- a/images/windows/toolsets/toolset-2025.json +++ b/images/windows/toolsets/toolset-2025.json @@ -76,8 +76,7 @@ "name": "az", "versions": [ "12.5.0" - ], - "zip_versions": [] + ] } ], "java": {