Monday, March 23, 2020

Get-AzKeyVaultSecret failing with 'Forbidden'

While preparing the pipeline scripts for the current project, I was not able to fetch the secrets form our KeyVault via Powershell using Get-AzKeyVaultSecret.

The Access Policies have been configured correctly and I was owner of the subscription.

Unfortunately, the KeyVault requires explicit 'owner' permissions on KeyVault level to make this work.



Error
Get-AzKeyVaultSecret : Operation returned an invalid status code 'Forbidden'

Solution
Grant owner permissions (temporarily) to your AD-User on KV-Level.

Cheers