0
votes

The Az.RecoveryServices powershell command Get-AzRecoveryServicesVault throws "Could not load file or assembly Microsoft.Azure.PowerShell.Authentication or one of its dependencies. The system cannot find the file specified" in the devops release pipeline. The command is executed in the Azure powershell task version 4.* in the pipeline. The difference I see with the last successful run is the version of Az.Accounts.

Import-Module -Name C:\Modules\az_3.8.0\Az.Accounts\1.8.1\Az.Accounts.psd1 -Global

During the successful run the Azure powershell task imported version 1.8.0.

Import-Module -Name C:\Modules\az_3.8.0\Az.Accounts\1.8.0\Az.Accounts.psd1 -Global
2

2 Answers

2
votes

Well, I can reproduce your issue on my side, looks it is a bug when using the Az.Accounts 1.8.1 along with the Az.RecoveryServices 2.8.0.

enter image description here

Per my test, to solve the issue, just use the Az.RecoveryServices 2.9.1, in the azure powershell task, there is no Az.RecoveryServices 2.9.1 installed by default currently, so we need to install and import it manually.

Try the commands below, it works fine on my side.

Install-Module -Name Az.RecoveryServices -RequiredVersion 2.9.1 -Force
Import-Module -Name Az.RecoveryServices -RequiredVersion 2.9.1
Get-AzRecoveryServicesVault -ResourceGroupName <group-name>

enter image description here

0
votes

Make sure to use Az.Accounts 1.9.0, in my case I had to remove higher ver and re-run the commands what Joy Wang mentioned above...