Install Az latest module

This commit is contained in:
Aleksandr Chebotov
2020-05-15 11:53:16 +03:00
parent 5308769e67
commit dba9085ec4

View File

@@ -9,21 +9,23 @@ source $HELPER_SCRIPTS/document.sh
# Install Azure CLI (instructions taken from https://docs.microsoft.com/en-us/cli/azure/install-azure-cli)
if isUbuntu20 ; then
sudo pwsh -Command 'Save-Module -Name Az -LiteralPath /usr/share/az_3.8.0 -RequiredVersion 3.8.0 -Force'
latestVersion=$(pwsh -Command '(Find-Module -Name Az).Version')
modulePath="/usr/share/az_$latestVersion"
echo "Save Az Module ($latestVersion) to $modulePath"
pwsh -Command "Save-Module -Name Az -LiteralPath $modulePath -RequiredVersion $latestVersion -Force"
# Run tests to determine that the software installed as expected
echo "Testing to make sure that script performed as expected, and basic scenarios work"
if ! pwsh -Command '$actualPSModulePath = $env:PSModulePath ; $env:PSModulePath = "/usr/share/az_3.8.0:" + $env:PSModulePath;
if (!(get-module -listavailable -name Az.accounts)) {
Write-Host "Az Module was not installed"; $env:PSModulePath = $actualPSModulePath; exit 1
}
$env:PSModulePath = $actualPSModulePath'; then
if ! pwsh -Command "\$env:PSModulePath = '${modulePath}:' + \$env:PSModulePath
if ( -not (Get-Module -ListAvailable -Name Az.Accounts)) {
Write-Host 'Az Module was not installed'
exit 1
}"; then
exit 1
fi
# Document what was added to the image
echo "Lastly, documenting what we added to the metadata file"
DocumentInstalledItem "Az Module (3.8.0)"
DocumentInstalledItem "Az Module ($latestVersion)"
exit 0
fi