Closed
Description
Hi,
Since a month ago retrieving keyvault access policies with arcus does not work anymore.
Using this step in the pipeline:
- task: AzurePowerShell@5
displayName: 'Retrieve KeyVault Access Policies'
inputs:
azureSubscription: ${{parameters.azureSubscription}}
scriptType: 'InlineScript'
azurePowerShellVersion: 'LatestVersion'
Inline: |
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted
Install-Module -Name Arcus.Scripting.KeyVault -Repository PSGallery -AllowClobber
$accessPolicies = Get-AzKeyVaultAccessPolicies -KeyVaultName $(InstallerApp.KeyVault.Name) -ResourceGroupName $(InstallerApp.ResourceGroup.Name)
$accessPoliciesjson = $accessPolicies | ConvertTo-Json -Depth 5 -Compress
Write-Host ("##vso[task.setvariable variable=InstallerApp.KeyVault.AccessPolicies;]$accessPoliciesjson")
This used to work like expected and the policies where retrieved however the following error started appearing since the middle of december 2024 (to my knowledge).
##[error]The 'Get-AzKeyVaultAccessPolicies' command was found in the module 'Arcus.Scripting.KeyVault', but the module could not be loaded. For more information, run 'Import-Module Arcus.Scripting.KeyVault'.
##[error]PowerShell exited with code '1'.
I was able to resolve this by installing the Az.Accounts module seperately in the pipeline before executing the step mentioned above. This results in the following steps:
- task: AzurePowerShell@5
displayName: 'Install Az.Accounts'
inputs:
azureSubscription: ${{parameters.azureSubscription}}
scriptType: 'InlineScript'
azurePowerShellVersion: 'LatestVersion'
Inline: |
Get-InstalledModule -Name Az.Accounts -AllVersions -ErrorAction SilentlyContinue | Uninstall-Module -Force -ErrorAction SilentlyContinue
Install-Module -Name Az.Accounts -Force -AllowClobber
- task: AzurePowerShell@5
displayName: 'Retrieve KeyVault Access Policies'
inputs:
azureSubscription: ${{parameters.azureSubscription}}
scriptType: 'InlineScript'
azurePowerShellVersion: 'LatestVersion'
Inline: |
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted
Install-Module -Name Arcus.Scripting.KeyVault -Repository PSGallery -AllowClobber
$accessPolicies = Get-AzKeyVaultAccessPolicies -KeyVaultName $(InstallerApp.KeyVault.Name) -ResourceGroupName $(InstallerApp.ResourceGroup.Name)
$accessPoliciesjson = $accessPolicies | ConvertTo-Json -Depth 5 -Compress
Write-Host ("##vso[task.setvariable variable=InstallerApp.KeyVault.AccessPolicies;]$accessPoliciesjson")
Doing this returns the expected behaviour.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status