I have a script that runs az cli commands (in powershell). For example, i’m using a commands like this in the script:
az keyvault secret list …
I pass parameters into the script, one of which is the keyvault name. For a given keyvault, i would like to return all the secrets in the keyvault that start with ‘app’. So for example, if the following secrets are in a keyvault:
app1name
app2name
app1password
dbpassword1
app2password
dbpassword2
i want to script to return a list that is:
app1name
app2name
app1password
app2password
2
Answers
I think you can do this with az keyvault secret list command along with some PowerShell filtering.
lemme share you a snippet below.
In my environment, I have KeyVault and created secrets with names like
app1name, app2name, app1password, dbpassword1, app2password, and dbpassword2.
as you mentioned.Portal:
To get the secret names with the prefix ‘app’ and output as
app1name, app2name, app1password, app2password
, you can use the command below.Command:
Output:
Reference:
az keyvault secret | Microsoft Learn