question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Keyvault][2.0.6] "az keyvault secret list" doesn't show "name" of secret, but download/show require it

See original GitHub issue

Description

To use keyvault as a rsa keystore, I’ll need to use download and show when I setting up new local machines (let alone servers in Azure). But both of those require --name of the secret. Unfortunately, the name value is not displayed by the output of list.

Result: I can’t script directly from list, because I have to put a sed from xargs in there to calculate the name from the id value that is returned.

GOAL: the metadata from list has the name value already in it so that you can easily script the keys from there without interpolating xargs/sed.

EXAMPLE:

az keyvault secret list --vault-name xxx
[
  {
    "attributes": {
      "created": "2017-05-28T09:50:49+00:00",
      "enabled": true,
      "expires": null,
      "notBefore": null,
      "updated": "2017-05-28T09:50:49+00:00"
    },
    "contentType": "Password-less private key for dcos demos",
    "id": "https://xxx.vault.azure.net/secrets/<name of key>",
    "managed": null,
    "tags": {
      "file-encoding": "utf-8"
    }
  }

Environment summary

Install Method: How did you install the CLI? (e.g. pip, interactive script, apt-get, Docker, MSI, nightly)
Answer here: sudo -H pip install azure-cli

CLI Version: What version of the CLI and modules are installed? (Use az --version)
Answer here: ╰─ az --version azure-cli (2.0.6)

acr (2.0.4) acs (2.0.6) appservice (0.1.6) batch (2.0.4) cdn (0.0.2) cloud (2.0.2) cognitiveservices (0.1.2) command-modules-nspkg (2.0.0) component (2.0.4) configure (2.0.6) core (2.0.6) cosmosdb (0.1.6) dla (0.0.6) dls (0.0.6) feedback (2.0.2) find (0.2.2) interactive (0.3.2) iot (0.1.5) keyvault (2.0.4) lab (0.0.4) monitor (0.0.4) network (2.0.6) nspkg (3.0.0) profile (2.0.4) rdbms (0.0.1) redis (0.2.3) resource (2.0.6) role (2.0.4) sf (1.0.1) sql (2.0.3) storage (2.0.6) vm (2.0.6)

Python (Darwin) 2.7.13 (default, Apr 4 2017, 08:47:57) [GCC 4.2.1 Compatible Apple LLVM 8.1.0 (clang-802.0.38)]

Python location ‘/usr/local/opt/python/bin/python2.7’

OS Version: What OS and version are you using?
Answer here: macOS Sierra, 10.12.5

Shell Type: What shell are you using? (e.g. bash, cmd.exe, Bash on Windows)
Answer here: oh-my-zsh

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:14 (9 by maintainers)

github_iconTop GitHub Comments

4reactions
shtratoscommented, Mar 14, 2018

Until this is fixed, here’s a workaround I use for reading secrets using bash and jq:

# this prints all the secrets in the keyvault
VAULT_NAME=my-key-vault
for i in `az keyvault secret list --vault-name $VAULT_NAME | jq  --raw-output '.[]|(.id / "/")[4]'`
do 
  az keyvault secret show --vault-name $VAULT_NAME --name $i 
done | jq --raw-output '[(.id / "/")[4], .value] | join("=")'
1reaction
squillacecommented, Jun 27, 2017

Hi @schaabs, not sure we should have you do the work for that if the server side is updated in the future. I just wanted THAT updated. But parsing the ID is ‘ok’ for now. I’d let this be the issue to fix the server and close it when that is done.

Read more comments on GitHub >

github_iconTop Results From Across the Web

az keyvault does not list secret - Stack Overflow
I'm using azure cli from the windows terminal azure cloud shell. ... but it only shows me a black screen. What am I...
Read more >
Manage Key Vault using the Azure CLI - Microsoft Learn
If you don't have an Azure subscription, create a free account before you begin. ... az keyvault secret list --vault-name "ContosoKeyVault".
Read more >
azure-keyvault-secrets - PyPI
A secret consists of a secret value and its associated metadata and management information. This library handles secret values as strings, but Azure...
Read more >
How to permanently delete a secret from Azure KeyVault ? - blog
Blog post about the 'soft delete' option in KeyVault in Azure. ... az keyvault secret list-deleted --vault-name KeyVault128463 az keyvault ...
Read more >
Copy Azure KeyVault secrets to another ... - Thomas Thornton
I am going to show how you can copy Azure KeyVault secrets to another KeyVault using ... SECRET_CHECK=$(az keyvault secret list --vault-name ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found