diff --git a/images/win/scripts/Installers/Install-AzureModules.ps1 b/images/win/scripts/Installers/Install-AzureModules.ps1 index a12dec60c..ec36fe6ff 100644 --- a/images/win/scripts/Installers/Install-AzureModules.ps1 +++ b/images/win/scripts/Installers/Install-AzureModules.ps1 @@ -36,6 +36,46 @@ foreach ($module in $modules) } } + if($null -ne $module.url) + { + $assets = Invoke-RestMethod $module.url + } + + 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 + } + } + } # Append default tool version to machine path if ($null -ne $module.default) { diff --git a/images/win/toolsets/toolset-2016.json b/images/win/toolsets/toolset-2016.json index f69b1cbda..9a1d2e5f5 100644 --- a/images/win/toolsets/toolset-2016.json +++ b/images/win/toolsets/toolset-2016.json @@ -90,30 +90,40 @@ "azureModules": [ { "name": "azurerm", + "blob_url": "https://vstsagenttools.blob.core.windows.net/tools/azurepowershellmodules/", "versions": [ "2.1.0", + "6.13.1" + ], + "zip_versions": [ "3.8.0", "4.2.1", "5.1.1", - "6.7.0", - "6.13.1" + "6.7.0" ], "default": "2.1.0" }, { "name": "azure", + "blob_url": "https://vstsagenttools.blob.core.windows.net/tools/azurepowershellmodules/", "versions": [ "2.1.0", + "5.3.0" + ], + "zip_versions": [ "3.8.0", "4.2.1", - "5.1.1", - "5.3.0" + "5.1.1" ], "default": "2.1.0" }, { "name": "az", + "url" : "https://raw.githubusercontent.com/Azure/az-ps-module-versions/main/versions-manifest.json", "versions": [ + "5.5.0" + ], + "zip_versions": [ "1.0.0", "1.6.0", "2.3.2", @@ -124,8 +134,7 @@ "4.3.0", "4.4.0", "4.6.0", - "4.7.0", - "5.5.0" + "4.7.0" ] } ], diff --git a/images/win/toolsets/toolset-2019.json b/images/win/toolsets/toolset-2019.json index 6c4b577af..6d1260559 100644 --- a/images/win/toolsets/toolset-2019.json +++ b/images/win/toolsets/toolset-2019.json @@ -90,30 +90,40 @@ "azureModules": [ { "name": "azurerm", + "blob_url": "https://vstsagenttools.blob.core.windows.net/tools/azurepowershellmodules/", "versions": [ "2.1.0", + "6.13.1" + ], + "zip_versions": [ "3.8.0", "4.2.1", "5.1.1", - "6.7.0", - "6.13.1" + "6.7.0" ], "default": "2.1.0" }, { "name": "azure", + "blob_url": "https://vstsagenttools.blob.core.windows.net/tools/azurepowershellmodules/", "versions": [ "2.1.0", + "5.3.0" + ], + "zip_versions": [ "3.8.0", "4.2.1", - "5.1.1", - "5.3.0" + "5.1.1" ], "default": "2.1.0" }, { "name": "az", + "url" : "https://raw.githubusercontent.com/Azure/az-ps-module-versions/main/versions-manifest.json", "versions": [ + "5.5.0" + ], + "zip_versions": [ "1.0.0", "1.6.0", "2.3.2", @@ -124,8 +134,7 @@ "4.3.0", "4.4.0", "4.6.0", - "4.7.0", - "5.5.0" + "4.7.0" ] } ],