Skip to content

Instantly share code, notes, and snippets.

@loneshark99
Last active November 26, 2021 20:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save loneshark99/430dfb937ab8bf2c4d97eebc4c09b296 to your computer and use it in GitHub Desktop.
Save loneshark99/430dfb937ab8bf2c4d97eebc4c09b296 to your computer and use it in GitHub Desktop.
View all keyvault keys/Secrets.
# If not installed, install az cli from https://aka.ms/installazurecliwindows
# Login to azure and then run the following script.
# az login
# python3 script.py | grep -i "YourKey"
import os
import pandas as pd
from azure.keyvault.secrets import SecretClient
from azure.identity import DefaultAzureCredential, _credentials
keyVaultName = os.environ["KEY_VAULT_NAME"]
KVUri = f"https://{keyVaultName}.vault.azure.net"
credentials = DefaultAzureCredential()
client = SecretClient(vault_url=KVUri, credential=credentials)
results = []
secretProperties = client.list_properties_of_secrets()
for secretProp in secretProperties:
secretValue = client.get_secret(secretProp.name)
results.append({secretProp.name, secretValue.value})
resultsDF = pd.DataFrame(results, columns=["Secret_Name", "Secret_Value"])
print(resultsDF)
#azure-common==1.1.27
#azure-core==1.20.1
#azure-identity==1.7.1
#azure-keyvault-secrets==4.3.0
#certifi==2021.10.8
#cffi==1.15.0
#charset-normalizer==2.0.8
#cryptography==36.0.0
#gobject==0.1.0
#idna==3.3
#isodate==0.6.0
#msal==1.16.0
#msal-extensions==0.3.0
#msrest==0.6.21
#numpy==1.21.4
#oauthlib==3.1.1
#pandas==1.3.4
#portalocker==1.7.1
#pycairo==1.20.1
#pycparser==2.21
#PyGObject==3.42.0
#PyJWT==2.3.0
#python-dateutil==2.8.2
#pytz==2021.3
#requests==2.26.0
#requests-oauthlib==1.3.0
#six==1.16.0
#urllib3==1.26.7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment