-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(secrets): POC reads value using azure libs
- Loading branch information
1 parent
00d7b00
commit 978cbca
Showing
1 changed file
with
22 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import sys | ||
|
||
from azure.identity import DefaultAzureCredential | ||
from azure.keyvault.secrets import SecretClient | ||
|
||
|
||
if __name__ == "__main__": | ||
args = sys.argv[1:] | ||
if len(args) < 2: | ||
print("Provide the Key Vault URL and the name of the secret to read") | ||
exit(1) | ||
|
||
vault_url = args[0] | ||
secret_name = args[1] | ||
|
||
credential = DefaultAzureCredential() | ||
client = SecretClient(vault_url=vault_url, credential=credential) | ||
secret = client.get_secret(secret_name) | ||
|
||
print(f"Reading {secret_name} from {vault_url}") | ||
print(f"Value: {secret.value}") | ||
exit(0) |