Reputation: 1565
I am using az keyvault secret list
to get secrets from my Azure key vault. Its help says:
Arguments
--maxresults : Maximum number of results to return in a page. If not
specified, the service will return up to 25 results.
It is not possible to set --maxresults
any higher than 25. The help says "in a page", but I can find no explanation of how to get the next page.
Is it possible to list more than the top 25 secrets using this tool?
Upvotes: 4
Views: 1946
Reputation: 53
To get all the secrets with name and value via azure cli in Mac, you can use the below script:
sh keyvault-list.sh keyvaultname
#!/usr/bin/env bash
keyvaultEntries=($(az keyvault secret list --vault-name $1 --query "[*].{name:name}" -o tsv))
for i in "${keyvaultEntries[@]}"
do
# do whatever on "$i" here
echo "$i"::"$(az keyvault secret show --name $i --vault-name $1 -o tsv --query value)"
done
Upvotes: 1
Reputation: 4776
We cannot get more than 25 Secret lists by using the --maxresults
in the CLI command.
If we specify the --maxresults
more than 25 the cli returns the below result.
Az keyvault secret list --vault-name <your keyvault name> --maxresults 30
If you want to get all the Secrets in a specific key vault you have to use the below command without using --maxresults
.
Az keyvault secret list --vault-name <your keyvault name>
Or If you want it to achieve programmatically need to write a script with the REST API or some language library directly. Refer here
Upvotes: 3