[Windows] Az Modules Size Reduction On Image (#2827)

* [Windows] Az Modules Size Reduction On Image

* Addressing review comments

* Downloading azure and azurerm from blob storage
This commit is contained in:
Amruta Kawade
2021-03-26 20:51:12 +05:30
committed by GitHub
parent 4c606d887d
commit f6f2e3681e
3 changed files with 70 additions and 12 deletions

View File

@@ -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 # Append default tool version to machine path
if ($null -ne $module.default) if ($null -ne $module.default)
{ {

View File

@@ -90,30 +90,40 @@
"azureModules": [ "azureModules": [
{ {
"name": "azurerm", "name": "azurerm",
"blob_url": "https://vstsagenttools.blob.core.windows.net/tools/azurepowershellmodules/",
"versions": [ "versions": [
"2.1.0", "2.1.0",
"6.13.1"
],
"zip_versions": [
"3.8.0", "3.8.0",
"4.2.1", "4.2.1",
"5.1.1", "5.1.1",
"6.7.0", "6.7.0"
"6.13.1"
], ],
"default": "2.1.0" "default": "2.1.0"
}, },
{ {
"name": "azure", "name": "azure",
"blob_url": "https://vstsagenttools.blob.core.windows.net/tools/azurepowershellmodules/",
"versions": [ "versions": [
"2.1.0", "2.1.0",
"5.3.0"
],
"zip_versions": [
"3.8.0", "3.8.0",
"4.2.1", "4.2.1",
"5.1.1", "5.1.1"
"5.3.0"
], ],
"default": "2.1.0" "default": "2.1.0"
}, },
{ {
"name": "az", "name": "az",
"url" : "https://raw.githubusercontent.com/Azure/az-ps-module-versions/main/versions-manifest.json",
"versions": [ "versions": [
"5.5.0"
],
"zip_versions": [
"1.0.0", "1.0.0",
"1.6.0", "1.6.0",
"2.3.2", "2.3.2",
@@ -124,8 +134,7 @@
"4.3.0", "4.3.0",
"4.4.0", "4.4.0",
"4.6.0", "4.6.0",
"4.7.0", "4.7.0"
"5.5.0"
] ]
} }
], ],

View File

@@ -90,30 +90,40 @@
"azureModules": [ "azureModules": [
{ {
"name": "azurerm", "name": "azurerm",
"blob_url": "https://vstsagenttools.blob.core.windows.net/tools/azurepowershellmodules/",
"versions": [ "versions": [
"2.1.0", "2.1.0",
"6.13.1"
],
"zip_versions": [
"3.8.0", "3.8.0",
"4.2.1", "4.2.1",
"5.1.1", "5.1.1",
"6.7.0", "6.7.0"
"6.13.1"
], ],
"default": "2.1.0" "default": "2.1.0"
}, },
{ {
"name": "azure", "name": "azure",
"blob_url": "https://vstsagenttools.blob.core.windows.net/tools/azurepowershellmodules/",
"versions": [ "versions": [
"2.1.0", "2.1.0",
"5.3.0"
],
"zip_versions": [
"3.8.0", "3.8.0",
"4.2.1", "4.2.1",
"5.1.1", "5.1.1"
"5.3.0"
], ],
"default": "2.1.0" "default": "2.1.0"
}, },
{ {
"name": "az", "name": "az",
"url" : "https://raw.githubusercontent.com/Azure/az-ps-module-versions/main/versions-manifest.json",
"versions": [ "versions": [
"5.5.0"
],
"zip_versions": [
"1.0.0", "1.0.0",
"1.6.0", "1.6.0",
"2.3.2", "2.3.2",
@@ -124,8 +134,7 @@
"4.3.0", "4.3.0",
"4.4.0", "4.4.0",
"4.6.0", "4.6.0",
"4.7.0", "4.7.0"
"5.5.0"
] ]
} }
], ],