I have these tasks in apipeline im using that is failing because it is using Az.Accounts version eariler than 2.19.0 (2.17.0)
”’
- task: PowerShell@2
displayName: ‘Insatll Az.Accounts’
inputs:
pwsh: true
targetType: ‘inline’
script: ‘Install-Module -Name Az.Accounts -RequiredVersion 2.19.0 -Repository PSGallery -Force - task: AzurePowerShell@5
displayName: ‘Export Cost Datea
inputs:
pwsh: true
azureSubscription: $serviceconnection
azurePowerShellVersion: LatestVersion
scriptType: ‘inlineScript’
inline: |
Update-Module -Name “Az.Accounts” -Force
Get-InstalledModule -Name “Az.Accounts”
Get-Module -ListAvailable
$azTenantId = (Get-AzContext).Tenant.Id
Write-host (Get-AzTenant | where-object Id -eq $azTenantId).Name
Install-Module Az.CostManagement -Scope CurrentUser -Force
Import-Module Az.CostManagement
Invoke-AzCostManagementExecuteReport -ExportName $costExport -Scope $scope
”’
essentially its just the invoke cost management export and all the other code is just there to get it to work. I can see that both versions are installed when I list the modules. How do I make the pipeline use the correct version?
I tried using this fix Azure Devops pipeline failing due to AZ.Accounts Module update by MSFT but it is no longer working. I also added the update module Line but it hasnt worked either and its still throwing the error