До сегодняшнего дня этот конвейер был настроен и работал. Однако, основываясь на недавнем обновлении модуля, я теперь получаю эту ошибку
Write-Error: This module requires Az.Accounts version 2.19.0. An earlier version of
Az.Accounts is imported in the current PowerShell session. Please open a new
session before importing this module. This error could indicate that multiple
incompatible versions of the Azure PowerShell cmdlets are installed on your
system. Please see https://aka.ms/azps-version-error for troubleshooting
information.
Я попытался добавить это в скрипт моего модуля, чтобы удалить существующий и установить новую версию 2.19.0. Но не повезло
$desiredVersion = "2.19.0"
$installedModule = Get-InstalledModule -Name "Az.Accounts" -ErrorAction SilentlyContinue
Write-Output "$($installedModule)"
if ($installedModule) {
if ($installedModule.Version.ToString() -ne $desiredVersion) {
Uninstall-Module -Name "Az.Accounts" -Force -ErrorAction SilentlyContinue
Install-Module -Name "Az.Accounts" -RequiredVersion $desiredVersion -Force -AllowClobber -Scope CurrentUser -Repository PSGallery
}
} else {
Install-Module -Name "Az.Accounts" -RequiredVersion $desiredVersion -Force -AllowClobber -Scope CurrentUser -Repository PSGallery
}
Import-Module Az.Accounts
Вы можете попробовать добавить задачу PowerShell перед задачей Azure PowerShell для установки модуля Az.Accounts 2.19.0
. См. пример ниже в качестве ссылки.
stages:
- stage: A
jobs:
- job: A1
pool:
vmImage: ubuntu-latest
steps:
- task: PowerShell@2
displayName: 'Install Module Az.Accounts'
inputs:
pwsh: true
targetType: 'inline'
script: 'Install-Module -Name Az.Accounts -RequiredVersion 2.19.0 -Repository PSGallery -Force'
- task: AzurePowerShell@5
displayName: 'Check Module Az.Accounts'
inputs:
pwsh: true
azureSubscription: 'myArmConnection'
ScriptType: 'InlineScript'
Inline: 'Get-InstalledModule -Name "Az.Accounts"'
azurePowerShellVersion: 'LatestVersion'