Azure cli command to display the count(number of ) secrets in keyvault

Barik, Monalisa 126 Reputation points
2023-08-08T04:08:36.84+00:00

I have retried the secrets from keyvault in csv file .I want to know is there any Azure cli command to display the count(number of ) secrets in key vault.

Kindly help us on the same.

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,448 questions
0 comments No comments
{count} votes

Accepted answer
  1. Marilee Turscak-MSFT 37,206 Reputation points Microsoft Employee Moderator
    2023-08-09T01:33:09.92+00:00

    Hi @Barik, Monalisa ,

    I understand that you are looking to display the count of secrets in your key vault. You can use these Powershell commands to retrieve those numbers:

    Number of secrets:

    (Get-AzKeyVaultSecret -VaultName xxx).count

    Number of certificates (if you want those too):

    (Get-AzKeyVaultCertificate -VaultName xxx).count

    I'm not sure whether Azure CLI has the commands for this (could not find this documented), so Powershell may be your best option. You can list the secrets via CLI though:

     - Secret list: https://docs.microsoft.com/en-us/cli/azure/keyvault/secret?view=azure-cli-latest#az-keyvault-secret-list 

    - Certificate list: https://docs.microsoft.com/en-us/cli/azure/keyvault/certificate?view=azure-cli-latest#az-keyvault-certificate-list

    Let me know if these options provided suit your needs.

    If the information helped you, please Accept the answer. This will help us as well as others in the community who may be researching similar questions.

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Barik, Monalisa 126 Reputation points
    2023-08-09T03:56:23.92+00:00

    Its working for me.

    Thanks a lot for support .

    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.