diff --git a/images/win/scripts/Installers/Install-AzureModules.ps1 b/images/win/scripts/Installers/Install-AzureModules.ps1 index d5a96ffb..66ebfe63 100644 --- a/images/win/scripts/Installers/Install-AzureModules.ps1 +++ b/images/win/scripts/Installers/Install-AzureModules.ps1 @@ -1,8 +1,14 @@ ################################################################################ ## File: Install-AzureModules.ps1 ## Desc: Install Azure PowerShell modules +## Supply chain security: package manager ################################################################################ +# +# prepares the environment for the Azure PowerShell modules +# used by AzureFileCopy@4, AzureFileCopy@5, AzurePowerShell@4, AzurePowerShell@5 tasks +# + # The correct Modules need to be saved in C:\Modules $installPSModulePath = "C:\\Modules" if (-not (Test-Path -LiteralPath $installPSModulePath)) @@ -25,56 +31,15 @@ foreach ($module in $modules) { $modulePath = Join-Path -Path $installPSModulePath -ChildPath "${moduleName}_${version}" Write-Host " - $version [$modulePath]" - try - { - Save-Module -Path $modulePath -Name $moduleName -RequiredVersion $version -Force -ErrorAction Stop - } - catch - { - Write-Host "Error: $_" - exit 1 - } - } - - if($null -ne $module.url) - { - $assets = Invoke-RestMethod $module.url + Save-Module -Path $modulePath -Name $moduleName -RequiredVersion $version -Force -ErrorAction Stop } foreach ($version in $module.zip_versions) { - # Install modules from GH Release - if($null -ne $assets) - { - $asset = $assets | Where-Object version -eq $version ` - | Select-Object -ExpandProperty files ` - | Select-Object -First 1 - - Write-Host "Installing $($module.name) $version ..." - if ($null -ne $asset) { - Start-DownloadWithRetry -Url $asset.download_url -Name $asset.filename -DownloadPath $installPSModulePath - } else { - Write-Host "Asset was not found in versions manifest" - exit 1 - } - } - # Install modules from vsts blob - else - { - $modulePath = Join-Path -Path $installPSModulePath -ChildPath "${moduleName}_${version}" - $filename = "${moduleName}_${version}.zip" - $download_url = [System.String]::Concat($module.blob_url,$filename) - Write-Host " - $version [$modulePath]" - try - { - Start-DownloadWithRetry -Url $download_url -Name $filename -DownloadPath $installPSModulePath - } - catch - { - Write-Host "Error: $_" - exit 1 - } - } + $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) diff --git a/images/win/toolsets/toolset-2019.json b/images/win/toolsets/toolset-2019.json index e54fdf49..db520b17 100644 --- a/images/win/toolsets/toolset-2019.json +++ b/images/win/toolsets/toolset-2019.json @@ -96,7 +96,6 @@ "azureModules": [ { "name": "azurerm", - "blob_url": "https://vstsagenttools.blob.core.windows.net/tools/azurepowershellmodules/", "versions": [ "2.1.0", "6.13.1" @@ -111,7 +110,6 @@ }, { "name": "azure", - "blob_url": "https://vstsagenttools.blob.core.windows.net/tools/azurepowershellmodules/", "versions": [ "2.1.0", "5.3.0" @@ -125,7 +123,6 @@ }, { "name": "az", - "url" : "https://raw.githubusercontent.com/Azure/az-ps-module-versions/main/versions-manifest.json", "versions": [ "9.3.0" ], diff --git a/images/win/toolsets/toolset-2022.json b/images/win/toolsets/toolset-2022.json index 138bc09e..9e4fa125 100644 --- a/images/win/toolsets/toolset-2022.json +++ b/images/win/toolsets/toolset-2022.json @@ -90,7 +90,6 @@ "azureModules": [ { "name": "azurerm", - "blob_url": "https://vstsagenttools.blob.core.windows.net/tools/azurepowershellmodules/", "versions": [ "2.1.0", "6.13.1" @@ -105,7 +104,6 @@ }, { "name": "azure", - "blob_url": "https://vstsagenttools.blob.core.windows.net/tools/azurepowershellmodules/", "versions": [ "2.1.0", "5.3.0" @@ -119,7 +117,6 @@ }, { "name": "az", - "url" : "https://raw.githubusercontent.com/Azure/az-ps-module-versions/main/versions-manifest.json", "versions": [ "9.3.0" ],