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

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 CLI 创建一个密钥保管库。In this quickstart, you create a key vault with the Azure CLI. Azure CLI 用于通过命令或脚本创建和管理 Azure 资源。The Azure CLI is used to create and manage Azure resources using commands or scripts. 如果选择在本地安装并使用 CLI,本快速入门要求 Azure CLI 2.0.4 或更高版本。If you choose to install and use the CLI locally, this quickstart requires the Azure CLI version 2.0.4 or later. 运行 az --version 即可查找版本。Run az --version to find the version. 如需进行安装或升级,请参阅安装 Azure CLIIf you need to install or upgrade, see Install the Azure CLI.

若要使用 CLI 登录到 Azure,可以键入:To sign in to Azure using the CLI you can type:

az cloud set -n AzureChinaCloud
az login

若要详细了解通过 CLI 使用的登录选项,请参阅使用 Azure CLI 登录For more information on login options via the CLI take a look at sign in with Azure CLI

创建资源组Create a resource group

资源组是在其中部署和管理 Azure 资源的逻辑容器。A resource group is a logical container into which Azure resources are deployed and managed. 以下示例在“chinaeast”位置创建名为“ContosoResourceGroup”的资源组。The following example creates a resource group named ContosoResourceGroup in the chinaeast location.

az group create --name "myResourceGroup" -l "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.

az keyvault create --name "<your-unique-keyvault-name>" --resource-group "myResourceGroup" --location "ChinaEast"

此 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 subsequent quickstarts and tutorials, you may wish to leave these resources in place.

如果不再需要资源组和所有相关的资源,可以使用 Azure CLI az group delete 命令将其删除:When no longer needed, you can use the Azure CLI az group delete command to remove the resource group and all related resources:

az group delete --name myResourceGroup

后续步骤Next steps

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