如何将多个密钥添加到 Azure Key Vault?

How to add multiple keys to Azure Key Vault?

我想加50个左右的键,想到了两种办法

  1. 通过将密钥添加到密钥保管库模板或
  2. 在PowerShell中使用add命令逐一添加密钥 但是太费时和重复了,那么有没有更简单的方法来添加这些键?

P/S- 我不想使用 Azure 门户创建密钥。

我们已经在本地环境中进行了测试,方法是在 csv 文件中创建 50 个密钥,并尝试使用以下 PowerShell 脚本将它们添加到密钥保管库中。完成脚本并在密钥保管库中创建 50 个密钥大约需要 3 分 06 秒。

这是 PowerShell 脚本:

 $Expires = (Get-Date).AddYears(2).ToUniversalTime()
$NotBefore = (Get-Date).ToUniversalTime()

Import-Csv C:\Users\Downloads\keys.csv|foreach{

Add-AzKeyVaultKey -VaultName '<keyvaultName>' -Name $_.Name -Destination 'Software' -Expires $Expires -NotBefore $NotBefore

}

这是供参考的屏幕截图:

这里是 Azure documentation add-azkeyvaultkey cmdlet 的参考,用于根据要求使用不同的参数创建密钥。