зеркало из https://github.com/microsoft/AI.git
Set secret (#2)
* Update realtimeserving-release.yml for Azure Pipelines * Update realtimeserving-release.yml for Azure Pipelines * script that will be used to capture storage connection string. * cleaning up entrypoint and printing out status of adding secret to keyvault
This commit is contained in:
Родитель
cf1993f6bf
Коммит
d8da7ffbd8
|
@ -3,6 +3,8 @@
|
|||
# Add steps that build, run tests, deploy, and more:
|
||||
# https://aka.ms/yaml
|
||||
|
||||
trigger:
|
||||
batch: true
|
||||
|
||||
stages:
|
||||
- stage: dev
|
||||
|
@ -70,4 +72,4 @@ stages:
|
|||
project: "e2etestharness"
|
||||
expires : "DnD"
|
||||
alias: $(Build.RequestedForId)
|
||||
agent: $(agent)
|
||||
agent: AI-GPU
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
import argparse
|
||||
from azure.keyvault import KeyVaultClient
|
||||
from azure.common.client_factory import get_client_from_cli_profile
|
||||
|
||||
|
||||
def set_secret(kv_endpoint, secret_name, secret_value):
|
||||
client = get_client_from_cli_profile(KeyVaultClient)
|
||||
|
||||
try:
|
||||
client.set_secret(kv_endpoint, secret_name, secret_value)
|
||||
return "Successfully created secret: {secret_name} in keyvault: {kv_endpoint}".format(
|
||||
secret_name=secret_name, kv_endpoint=kv_endpoint)
|
||||
except Exception as ex:
|
||||
return "Failed to create secret: {secret_name} in keyvault: {kv_endpoint}".format(
|
||||
secret_name=secret_name, kv_endpoint=kv_endpoint)
|
||||
|
||||
|
||||
def parse_args():
|
||||
parser = argparse.ArgumentParser()
|
||||
|
||||
parser.add_argument('-n', '--secretName', required=True,
|
||||
help="The name of the secret")
|
||||
parser.add_argument('-v', '--secretValue', required=True,
|
||||
help="The value of the secret")
|
||||
|
||||
return parser.parse_args()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
# hard coded for now
|
||||
kv_endpoint = "https://t3scriptkeyvault.vault.azure.net/"
|
||||
args = parse_args()
|
||||
message = set_secret(
|
||||
kv_endpoint, args.secretName, args.secretValue)
|
||||
|
||||
print(message)
|
Загрузка…
Ссылка в новой задаче