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

发布于 2025-01-12 18:40:33 字数 110 浏览 4 评论 0原文

抱歉,这里是菜鸟。也许这是一个非常简单和明显的答案,但我正在尝试存储大量的密钥库秘密,并且正在寻找一种与一次输入每个密钥相比更简单的方法。我认为使用 CLI 比 Azure 资源管理器界面更快地完成此任务。

Sorry, Noobie here. 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. I figure using the CLI would be a quicker way to get this done than the Azure Resource Manager interface.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

櫻之舞 2025-01-19 18:40:33

如果“ARM 接口”指的是模板,则已经为此情况编写了一个模板:https://github.com/Azure/azure-quickstart-templates/tree/master/quickstarts/microsoft.keyvault/key-vault-secret-create

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

冰魂雪魄 2025-01-19 18:40:33

不知道这是否真的会对任何人有帮助,因为它太基本了,但我最终在 bash 中创建了一个 for 循环脚本,它将输入文件作为变量并动态创建 keyvault 并使用基于 value.txt 的值填充所述 keyvault姓名。

运行:

bash keyvault_creator.sh key.txt vault1.txt

运行:

#!/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

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.

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文