Skip to content

Commit

Permalink
Update PS AzureRM -> Az (#19879)
Browse files Browse the repository at this point in the history
* Update PS AzureRM -> Az

- Remove AzureRM only if it was installed
- Try to initialize az modules only certain versions

* Update PS AzureRM -> Az

- Remove AzureRM only if it was installed
- Try to initialize az modules only certain versions

* Update PS AzureRM -> Az

- Remove AzureRM only if it was installed
- Try to initialize az modules only certain versions
  • Loading branch information
DmitriiBobreshev authored May 16, 2024
1 parent e285285 commit f5b22d9
Show file tree
Hide file tree
Showing 62 changed files with 184 additions and 187 deletions.
4 changes: 2 additions & 2 deletions Tasks/AzureCloudPowerShellDeploymentV1/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
"author": "Microsoft Corporation",
"version": {
"Major": 1,
"Minor": 239,
"Patch": 2
"Minor": 240,
"Patch": 0
},
"demands": [
"azureps"
Expand Down
4 changes: 2 additions & 2 deletions Tasks/AzureCloudPowerShellDeploymentV1/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
"author": "Microsoft Corporation",
"version": {
"Major": 1,
"Minor": 239,
"Patch": 2
"Minor": 240,
"Patch": 0
},
"demands": [
"azureps"
Expand Down
4 changes: 2 additions & 2 deletions Tasks/AzureCloudPowerShellDeploymentV2/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
"author": "Microsoft Corporation",
"version": {
"Major": 2,
"Minor": 239,
"Patch": 2
"Minor": 240,
"Patch": 0
},
"demands": [
"azureps"
Expand Down
4 changes: 2 additions & 2 deletions Tasks/AzureCloudPowerShellDeploymentV2/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
"author": "Microsoft Corporation",
"version": {
"Major": 2,
"Minor": 239,
"Patch": 2
"Minor": 240,
"Patch": 0
},
"demands": [
"azureps"
Expand Down
4 changes: 2 additions & 2 deletions Tasks/AzureFileCopyV1/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"author": "Microsoft Corporation",
"version": {
"Major": 1,
"Minor": 239,
"Patch": 4
"Minor": 240,
"Patch": 0
},
"demands": [
"azureps"
Expand Down
4 changes: 2 additions & 2 deletions Tasks/AzureFileCopyV1/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"author": "Microsoft Corporation",
"version": {
"Major": 1,
"Minor": 239,
"Patch": 4
"Minor": 240,
"Patch": 0
},
"demands": [
"azureps"
Expand Down
4 changes: 2 additions & 2 deletions Tasks/AzureFileCopyV2/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"author": "Microsoft Corporation",
"version": {
"Major": 2,
"Minor": 239,
"Patch": 6
"Minor": 240,
"Patch": 0
},
"demands": [
"azureps"
Expand Down
4 changes: 2 additions & 2 deletions Tasks/AzureFileCopyV2/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"author": "Microsoft Corporation",
"version": {
"Major": 2,
"Minor": 239,
"Patch": 6
"Minor": 240,
"Patch": 0
},
"demands": [
"azureps"
Expand Down
4 changes: 2 additions & 2 deletions Tasks/AzureFileCopyV3/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"author": "Microsoft Corporation",
"version": {
"Major": 3,
"Minor": 239,
"Patch": 6
"Minor": 240,
"Patch": 0
},
"demands": [
"azureps"
Expand Down
4 changes: 2 additions & 2 deletions Tasks/AzureFileCopyV3/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"author": "Microsoft Corporation",
"version": {
"Major": 3,
"Minor": 239,
"Patch": 6
"Minor": 240,
"Patch": 0
},
"demands": [
"azureps"
Expand Down
4 changes: 2 additions & 2 deletions Tasks/AzureFileCopyV4/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"author": "Microsoft Corporation",
"version": {
"Major": 4,
"Minor": 239,
"Patch": 6
"Minor": 240,
"Patch": 0
},
"demands": [
"azureps"
Expand Down
4 changes: 2 additions & 2 deletions Tasks/AzureFileCopyV4/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"author": "Microsoft Corporation",
"version": {
"Major": 4,
"Minor": 239,
"Patch": 6
"Minor": 240,
"Patch": 0
},
"demands": [
"azureps"
Expand Down
4 changes: 2 additions & 2 deletions Tasks/AzureFileCopyV5/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"author": "Microsoft Corporation",
"version": {
"Major": 5,
"Minor": 239,
"Patch": 8
"Minor": 240,
"Patch": 0
},
"demands": [
"azureps"
Expand Down
4 changes: 2 additions & 2 deletions Tasks/AzureFileCopyV5/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"author": "Microsoft Corporation",
"version": {
"Major": 5,
"Minor": 239,
"Patch": 8
"Minor": 240,
"Patch": 0
},
"demands": [
"azureps"
Expand Down
2 changes: 1 addition & 1 deletion Tasks/AzureFileCopyV6/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"version": {
"Major": 6,
"Minor": 240,
"Patch": 0
"Patch": 2
},
"demands": [
"azureps"
Expand Down
2 changes: 1 addition & 1 deletion Tasks/AzureFileCopyV6/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"version": {
"Major": 6,
"Minor": 240,
"Patch": 0
"Patch": 2
},
"demands": [
"azureps"
Expand Down
4 changes: 2 additions & 2 deletions Tasks/AzurePowerShellV2/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
"author": "Microsoft Corporation",
"version": {
"Major": 2,
"Minor": 239,
"Patch": 2
"Minor": 240,
"Patch": 0
},
"demands": [
"azureps"
Expand Down
4 changes: 2 additions & 2 deletions Tasks/AzurePowerShellV2/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
"author": "Microsoft Corporation",
"version": {
"Major": 2,
"Minor": 239,
"Patch": 2
"Minor": 240,
"Patch": 0
},
"demands": [
"azureps"
Expand Down
4 changes: 2 additions & 2 deletions Tasks/AzurePowerShellV3/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
"author": "Microsoft Corporation",
"version": {
"Major": 3,
"Minor": 239,
"Patch": 2
"Minor": 240,
"Patch": 0
},
"releaseNotes": "Added support for Fail on standard error and ErrorActionPreference",
"demands": [
Expand Down
4 changes: 2 additions & 2 deletions Tasks/AzurePowerShellV3/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
"author": "Microsoft Corporation",
"version": {
"Major": 3,
"Minor": 239,
"Patch": 2
"Minor": 240,
"Patch": 0
},
"releaseNotes": "ms-resource:loc.releaseNotes",
"demands": [
Expand Down
4 changes: 2 additions & 2 deletions Tasks/AzurePowerShellV4/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
"author": "Microsoft Corporation",
"version": {
"Major": 4,
"Minor": 239,
"Patch": 6
"Minor": 240,
"Patch": 0
},
"releaseNotes": "Added support for Az Module and cross platform agents.",
"groups": [
Expand Down
4 changes: 2 additions & 2 deletions Tasks/AzurePowerShellV4/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
"author": "Microsoft Corporation",
"version": {
"Major": 4,
"Minor": 239,
"Patch": 6
"Minor": 240,
"Patch": 0
},
"releaseNotes": "ms-resource:loc.releaseNotes",
"groups": [
Expand Down
4 changes: 2 additions & 2 deletions Tasks/AzurePowerShellV5/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
"author": "Microsoft Corporation",
"version": {
"Major": 5,
"Minor": 239,
"Patch": 10
"Minor": 240,
"Patch": 0
},
"releaseNotes": "Added support for Az Module and cross platform agents.",
"groups": [
Expand Down
4 changes: 2 additions & 2 deletions Tasks/AzurePowerShellV5/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
"author": "Microsoft Corporation",
"version": {
"Major": 5,
"Minor": 239,
"Patch": 10
"Minor": 240,
"Patch": 0
},
"releaseNotes": "ms-resource:loc.releaseNotes",
"groups": [
Expand Down
27 changes: 12 additions & 15 deletions Tasks/Common/VstsAzureHelpers_/InitializeAzModuleFunctions.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ function Initialize-AzModules {

try {
$azAccountsModuleName = "Az.Accounts"
$azAccountsVersion = Import-SpecificAzModule -moduleName $azAccountsModuleName -tryInstallModule:$tryInstallModule
$azAccountsVersion = Import-SpecificAzModule -moduleName $azAccountsModuleName -tryInstallModule:$tryInstallModule -minimumMajorVersion 2
Write-Verbose "'$azAccountsModuleName' is available with version $azAccountsVersion."

# Update-AzConfig is a part of Az.Accounts
Expand All @@ -112,11 +112,11 @@ function Initialize-AzModules {
}

$azResourcesModuleName = "Az.Resources"
$azResourcesVersion = Import-SpecificAzModule -moduleName $azResourcesModuleName -tryInstallModule:$tryInstallModule
$azResourcesVersion = Import-SpecificAzModule -moduleName $azResourcesModuleName -tryInstallModule:$tryInstallModule -minimumMajorVersion 6
Write-Verbose "'$azResourcesModuleName' is available with version $azResourcesVersion."

$azStorageModuleName = "Az.Storage"
$azStorageVersion = Import-SpecificAzModule -moduleName $azStorageModuleName -tryInstallModule:$tryInstallModule
$azStorageVersion = Import-SpecificAzModule -moduleName $azStorageModuleName -tryInstallModule:$tryInstallModule -minimumMajorVersion 4
Write-Verbose "'$azStorageModuleName' is available with version $azStorageVersion."
return $azAccountsVersion
} finally {
Expand All @@ -133,14 +133,17 @@ function Import-SpecificAzModule {
[string]$moduleName,

[Parameter()]
[switch]$tryInstallModule
[switch]$tryInstallModule,

[Parameter(Mandatory=$true)]
[int]$minimumMajorVersion
)
Trace-VstsEnteringInvocation $MyInvocation
try {
Write-Verbose "Attempting to find the latest available version of module '$moduleName'."
$module = Get-Module -Name $moduleName -ListAvailable | Sort-Object Version -Descending | Select-Object -First 1

if ($module) {
if ($module -and ($module.Version.Major -ge $minimumMajorVersion)) {
Write-Verbose "Module '$moduleName' version $($module.Version) was found."
} elseif ($tryInstallModule -eq $true) {
Write-Verbose "Unable to find module '$moduleName' from the module path. Installing '$moduleName' module."
Expand All @@ -150,8 +153,8 @@ function Import-SpecificAzModule {
$module = Get-Module -Name $moduleName -ListAvailable | Sort-Object Version -Descending | Select-Object -First 1
}

if (-not $module) {
throw (Get-VstsLocString -Key AZ_ModuleNotFound -ArgumentList $moduleName)
if (-not $module -or ($module.Version.Major -lt $minimumMajorVersion) ) {
throw (Get-VstsLocString -Key AZ_ModuleNotFound -ArgumentList $minimumMajorVersion, $moduleName)
}

Write-Host "##[command]Import-Module -Name $($module.Path) -Global -PassThru -Force"
Expand Down Expand Up @@ -223,16 +226,10 @@ function Uninstall-AzureRMModules {
Write-Verbose "Uninstalling AzureRM modules."

if ((Get-Module -ListAvailable -Name Az.Accounts) -and (Get-Command Uninstall-AzureRm -ErrorAction SilentlyContinue)) {
Write-Host "##[command]Uninstall-AzureRm"
Uninstall-AzureRm

Write-Verbose "Making sure all AzureRM modules are gone after the uninstall."

$azureRmModules = Get-Module -ListAvailable -Name AzureRM.* | Select-Object Name,Version
if ($azureRmModules) {
Foreach ($azureRmModule in $azureRmModules) {
Write-Verbose "'$($azureRmModule)' AzureRM module found."
}
Write-Host "##[command]Uninstall-AzureRm"
Uninstall-AzureRm
}
else {
Write-Verbose "No AzureRM modules found."
Expand Down
4 changes: 2 additions & 2 deletions Tasks/SqlAzureDacpacDeploymentV1/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
"author": "Microsoft Corporation",
"version": {
"Major": 1,
"Minor": 239,
"Patch": 2
"Minor": 240,
"Patch": 0
},
"demands": [
"sqlpackage"
Expand Down
4 changes: 2 additions & 2 deletions Tasks/SqlAzureDacpacDeploymentV1/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
"author": "Microsoft Corporation",
"version": {
"Major": 1,
"Minor": 239,
"Patch": 2
"Minor": 240,
"Patch": 0
},
"demands": [
"sqlpackage"
Expand Down
4 changes: 2 additions & 2 deletions _generated/AzureFileCopyV2.versionmap.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Default|2.239.6
Node20_229_2|2.239.7
Default|2.240.0
Node20_229_2|2.240.1
8 changes: 4 additions & 4 deletions _generated/AzureFileCopyV2/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"author": "Microsoft Corporation",
"version": {
"Major": 2,
"Minor": 239,
"Patch": 6
"Minor": 240,
"Patch": 0
},
"demands": [
"azureps"
Expand Down Expand Up @@ -374,7 +374,7 @@
"ExpiredServicePrincipal": "Could not fetch access token for Azure. Verify if the Service Principal used is valid and not expired."
},
"_buildConfigMapping": {
"Default": "2.239.6",
"Node20_229_2": "2.239.7"
"Default": "2.240.0",
"Node20_229_2": "2.240.1"
}
}
Loading

0 comments on commit f5b22d9

Please sign in to comment.