简体   繁体   English

使用一个 Azure CLI 命令将多个机密存储在 Keyvault 中

[英]Store multiple secrets in Keyvault with one Azure Cli command

Sorry, Noobie here.抱歉,这里是 Noobie。 Perhaps it is a very easy and obvious answer but I am trying to store an extensive list of keyvault secrets and am looking for an easy-ish way to do it compared with entering each one at a time.也许这是一个非常简单明了的答案,但我正在尝试存储大量的 keyvault 秘密,并且正在寻找一种与一次输入每个秘密相比更简单的方法来做到这一点。 I figure using the CLI would be a quicker way to get this done than the Azure Resource Manager interface.我认为使用 CLI 比 Azure 资源管理器界面更快捷。

If by "ARM Interface" you mean a template, there is a template already written for this case: https://github.com/Azure/azure-quickstart-templates/tree/master/quickstarts/microsoft.keyvault/key-vault-secret-create如果“ARM 接口”是指模板,那么已经为这种情况编写了一个模板: https://github.com/Azure/azure-quickstart-templates/tree/master/quickstarts/microsoft.keyvault/key-vault -秘密创建

Don't know if this will actually help anyone because its so basic but I ended up creating a for loop script in bash that takes the input files as variables and dynamically creates the keyvault and populates said keyvault with the values based on the values.txt name.不知道这是否真的对任何人有帮助,因为它太基础了,但我最终在 bash 中创建了一个 for 循环脚本,它将输入文件作为变量并动态创建 keyvault 并使用基于 values.txt 的值填充所述 keyvault名称。

running:跑步:

bash keyvault_creator.sh key.txt vault1.txt

runs:运行:

#!/bin/bash

key=$1
value=$2

az keyvault create --location <location> --name "${value%.*}" --resource-group <ResourceGroupName>

paste $key $value | while read if of; do
  echo "$if" "$of"
  az keyvault secret set --vault-name "${value%.*}" --name "$if" --value "$of"
done

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 从本地服务器获取 Azure KeyVault 机密 - Get Azure KeyVault secrets from On-Prem Server 使用 ARM 模板从 KeyVault 获取 Azure KeyVault 机密到应用服务 - Get Azure KeyVault Secrets from the KeyVault to an App Service using ARM Templates 在同一个 arm 模板部署中创建多个密钥库机密 - Creating multiple keyvault secrets in same arm template deployment 如何在经典 Azure DevOps 管道中存储 AWS CLI 命令的结果 - How to store result of a AWS CLI command in Classic Azure DevOps Pipeline 需要有关将机密更新到 KeyVault 的建议 - Need recommendation on updating secrets to KeyVault 如何将一个订阅下的一个 azure 租户(帐户)keyvault 中的密钥共享到另一个订阅中的另一个 azure 租户(帐户)keyvault - How to share a key from one azure tenant(account) keyvault under one subscription to another azure tenant(account) keyvault in another subscription Azure SDK 为 Go - 为什么有多个 KeyVault 和 blob 存储客户端? - Azure SDK for Go - why are there multiple KeyVault and blob storage clients? Azure CLI 将值传递给其他命令 Azure 命令 - Azure CLI Passing Value To Other Azure Command 在 Azure 中国连接到 KeyVault - Connect to KeyVault in Azure China 使用 Azure Keyvault 优化 GetSecret - Optimization for GetSecret with Azure Keyvault
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM