快速入门:使用 PowerShell 创建密钥保管库Quickstart: Create a key vault using PowerShell

Azure Key Vault 是一项云服务,它为密钥机密证书提供了安全的存储。Azure Key Vault is a cloud service that provides a secure store for keys, secrets, and certificates. 有关 Key Vault 的详细信息,请参阅关于 Azure Key Vault;有关密钥保管库中可存储的内容的详细信息,请参阅关于密钥、机密和证书For more information on Key Vault, see About Azure Key Vault; for more information on what can be stored in a key vault, see About keys, secrets, and certificates.

如果没有 Azure 订阅,可在开始前创建一个试用帐户If you don't have an Azure subscription, create a trial account before you begin.

在本快速入门中,你将使用 Azure PowerShell 创建一个密钥保管库。In this quickstart, you create a key vault with Azure PowerShell. 如果选择在本地安装并使用 PowerShell,则本教程需要 Azure PowerShell 模块 1.0.0 或更高版本。If you choose to install and use PowerShell locally, this tutorial requires Azure PowerShell module version 1.0.0 or later. 键入 $PSVersionTable.PSVersion 即可查找版本。Type $PSVersionTable.PSVersion to find the version. 如果需要进行升级,请参阅 Install Azure PowerShell module(安装 Azure PowerShell 模块)。If you need to upgrade, see Install Azure PowerShell module. 如果在本地运行 PowerShell,则还需运行 Login-AzAccount 来创建与 Azure 的连接。If you are running PowerShell locally, you also need to run Login-AzAccount to create a connection with Azure.

Login-AzAccount

创建资源组Create a resource group

使用 New-AzResourceGroup 创建 Azure 资源组。Create an Azure resource group with New-AzResourceGroup. 资源组是在其中部署和管理 Azure 资源的逻辑容器。A resource group is a logical container into which Azure resources are deployed and managed.

New-AzResourceGroup -Name 'myResourceGroup" -Location "ChinaEast"

创建 key vaultCreate a key vault

在上一步骤创建的资源组中创建 Key Vault。Create a Key Vault in the resource group from the previous step. 需要提供某些信息:You will need to provide some information:

  • Key Vault 名称:由 3 到 24 个字符构成的字符串,只能包含数字 (0-9)、字母(a-z、A-Z)和连字符 (-)Key vault name: A string of 3 to 24 characters that can contain only numbers (0-9), letters (a-z, A-Z), and hyphens (-)

    重要

    每个密钥保管库必须具有唯一的名称。Each key vault must have a unique name. 在以下示例中,将 替换为密钥保管库的名称。Replace with the name of your key vault in the following examples.

  • 资源组名称:myResourceGroup。Resource group name: myResourceGroup.

  • 位置:ChinaEastThe location: ChinaEast.

New-AzKeyVault -Name "<your-unique-key-vault-name> -ResourceGroupName "myResourceGroup" -Location "China East"

此 cmdlet 的输出显示新创建的密钥保管库的属性。The output of this cmdlet shows properties of the newly created key vault. 请记下下面列出的两个属性:Take note of the two properties listed below:

  • 保管库名称:为上面的 --name 参数提供的名称。Vault Name: The name you provided to the --name parameter above.
  • 保管库 URI:在本示例中为 https://<your-unique-keyvault-name>.vault.azure.cn/。Vault URI: In the example, this is https://<your-unique-keyvault-name>.vault.azure.cn/. 通过其 REST API 使用保管库的应用程序必须使用此 URI。Applications that use your vault through its REST API must use this URI.

目前,只有你的 Azure 帐户才有权对这个新保管库执行任何操作。At this point, your Azure account is the only one authorized to perform any operations on this new vault.

清理资源Clean up resources

本系列中的其他快速入门和教程是在本快速入门的基础上制作的。Other quickstarts and tutorials in this collection build upon this quickstart. 如果打算继续使用其他快速入门和教程,则可能需要保留这些资源。If you plan to continue on to work with other quickstarts and tutorials, you may want to leave these resources in place.

如果不再需要资源组和所有相关资源,可以使用 Azure PowerShell Remove-AzResourceGroup 命令将其删除。When no longer needed, you can use the Azure PowerShell Remove-AzResourceGroup command to remove the resource group and all related resources.

Remove-AzResourceGroup -Name "myResourceGroup"

后续步骤Next steps

在本快速入门中,你创建了 Key Vault 并在其中存储了一个机密。In this quickstart you created a Key Vault and stored a secret in it. 若要详细了解 Key Vault 以及如何将其与应用程序集成,请继续阅读以下文章。To learn more about Key Vault and how to integrate it with your applications, continue on to the articles below.