How to read/show access policy from Azure CLI or Powershell

Jérôme DEMEULLE 20 Reputation points
2023-10-20T09:46:47.14+00:00

Hi there,

We are working with keyvaults that have Vault Access Policy set. I am looking for a way to read or show these access policies from either Azure CLI or Powershell. I am aware of the az keyvault set-policy command to define the policy, but I cannot find an equivalent get-policy command.

Can someone help me find a way to do this with batch command because we need to automate the process for generating reports.

Azure Key Vault
Azure Key Vault
An Azure service that is used to manage and protect cryptographic keys and other secrets used by cloud apps and services.
1,452 questions
0 comments No comments
{count} votes

Accepted answer
  1. Konstantinos Passadis 19,591 Reputation points MVP
    2023-10-20T10:13:47.11+00:00

    Hello @Jérôme DEMEULLE

    Welcome to Microsoft QnA!

    Please use :

    Pshell:> (Get-AzKeyVault -VaultName mykeyvault).AccessPolicies

    Sample Output :

    Tenant ID : xxxxxxxx

    Object ID : xxxxxxxx

    Application ID :

    Display Name :

    Permissions to Keys : {Get, List, Update, Create…}

    Permissions to Secrets : {Get, List, Set, Delete…}

    Permissions to Certificates : {Get, List, Update, Create…}

    Permissions to (Key Vault Managed) Storage : {}

    Tenant ID : xxxxxxxxxx

    Object ID : xxxxxxxx

    Application ID :

    Display Name : aciapi (xxxxxxxxxx)

    Permissions to Keys : {Get, List, Update, Create…}

    Permissions to Secrets : {}

    Permissions to Certificates : {}

    Permissions to (Key Vault Managed) Storage : {}

    The Az Cli does not offer such detail

    Reference :

    az keyvault show --name YourKeyVaultName --query "properties.accessPolicies"


    I hope this helps!

    Kindly mark the answer as Accepted and Upvote in case it helped!

    Regards

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Andreas Baumgarten 123.6K Reputation points MVP Volunteer Moderator
    2023-10-20T10:01:52.2566667+00:00

    Hi @Jérôme DEMEULLE ,

    maybe this one line in PowerShell is helpful:

    (Get-AzKeyVault -VaultName <keyvaultname>).AccessPolicies
    

    (If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)

    Regards

    Andreas Baumgarten

    2 people found this answer helpful.
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.