您现在访问的是微软AZURE全球版技术文档网站,若需要访问由世纪互联运营的MICROSOFT AZURE中国区技术文档网站,请访问 https://docs.azure.cn.

快速入门:通过 Azure CLI 创建 Azure 区块链服务区块链成员Quickstart: Create an Azure Blockchain Service blockchain member using Azure CLI

本快速入门介绍如何使用 Azure CLI 在 Azure 区块链服务中部署新的区块链成员和联盟。In this quickstart, you deploy a new blockchain member and consortium in Azure Blockchain Service using Azure CLI.

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

启动 Azure Cloud ShellLaunch Azure Cloud Shell

Azure Cloud Shell 是免费的交互式 shell,可以使用它运行本文中的步骤。The Azure Cloud Shell is a free interactive shell that you can use to run the steps in this article. 它预安装有常用 Azure 工具并将其配置与帐户一起使用。It has common Azure tools preinstalled and configured to use with your account.

若要打开 Cloud Shell,只需要从代码块的右上角选择“试一试”。 To open the Cloud Shell, just select Try it from the upper right corner of a code block. 也可以通过转到 https://shell.azure.com/bash 在单独的浏览器标签页中启动 Cloud Shell。You can also launch Cloud Shell in a separate browser tab by going to https://shell.azure.com/bash. 选择“复制”以复制代码块,将其粘贴到 Cloud Shell 中,然后按 Enter 来运行它。 Select Copy to copy the blocks of code, paste it into the Cloud Shell, and press enter to run it.

如果希望在本地安装并使用 CLI,则本快速入门需要 Azure CLI 2.0.51 版或更高版本。If you prefer to install and use the CLI locally, this quickstart requires Azure CLI version 2.0.51 or later. 运行 az --version 即可查找版本。Run az --version to find the version. 如果需要进行安装或升级,请参阅安装 Azure CLIIf you need to install or upgrade, see install Azure CLI.

创建资源组Create a resource group

使用“az group create”命令创建资源组。Create a resource group with the az group create command. Azure 资源组是在其中部署和管理 Azure 资源的逻辑容器。An Azure resource group is a logical container into which Azure resources are deployed and managed. 以下示例在 eastus 位置创建名为 myResourceGroup 的资源组: The following example creates a resource group named myResourceGroup in the eastus location:

az group create \
                 --name myResourceGroup \
                 --location westus2

创建区块链成员Create a blockchain member

Azure 区块链服务成员是专用联盟区块链网络中的区块链节点。An Azure Blockchain Service member is a blockchain node in a private consortium blockchain network. 预配成员时,可以创建或加入联盟网络。When provisioning a member, you can create or join a consortium network. 至少需要一个联盟网络的成员。You need at least one member for a consortium network. 参与者所需的区块链成员数取决于方案。The number of blockchain members needed by participants depends on your scenario. 联盟参与者可能有一个或多个区块链成员,或者与其他参与者共享成员。Consortium participants may have one or more blockchain members or they may share members with other participants. 有关联盟的详细信息,请参阅 Azure 区块链服务联盟For more information on consortia, see Azure Blockchain Service consortium.

需要传递多个参数和属性。There are several parameters and properties you need to pass. 将示例参数替换为你自己的值。Replace the example parameters with your values.

az resource create \
                    --resource-group myResourceGroup \
                    --name myblockchainmember \
                    --resource-type Microsoft.Blockchain/blockchainMembers \
                    --is-full-object \
                    --properties '{"location":"westus2", "properties":{"password":"strongMemberAccountPassword@1", "protocol":"Quorum", "consortium":"myConsortiumName", "consortiumManagementAccountPassword":"strongConsortiumManagementPassword@1"}, "sku":{"name":"S0"}}'
参数Parameter 说明Description
resource-groupresource-group 在其中创建 Azure 区块链服务资源的资源组名称。Resource group name where Azure Blockchain Service resources are created. 请使用在上一部分中创建的资源组。Use the resource group you created in the previous section.
name name 用于标识 Azure 区块链服务区块链成员的唯一名称。A unique name that identifies your Azure Blockchain Service blockchain member. 此名称用于公共终结点地址。The name is used for the public endpoint address. 例如,myblockchainmember.blockchain.azure.comFor example, myblockchainmember.blockchain.azure.com.
locationlocation 在其中创建区块链成员的 Azure 区域。Azure region where the blockchain member is created. 例如,westus2For example, westus2. 选择最靠近用户或其他 Azure 应用程序的位置。Choose the location that is closest to your users or your other Azure applications.
password password 成员的默认事务节点的密码。The password for the member's default transaction node. 连接到区块链成员的默认事务节点公共终结点时,请使用密码进行基本身份验证。Use the password for basic authentication when connecting to blockchain member's default transaction node public endpoint.
consortiumconsortium 要加入或创建的联盟的名称。Name of the consortium to join or create. 有关联盟的详细信息,请参阅 Azure 区块链服务联盟For more information on consortia, see Azure Blockchain Service consortium.
consortiumAccountPasswordconsortiumAccountPassword 联盟帐户密码也称为成员帐户密码。The consortium account password is also known as the member account password. 成员帐户密码用于加密为你的成员创建的 Ethereum 帐户的私钥。The member account password is used to encrypt the private key for the Ethereum account that is created for your member. 你使用成员帐户和成员帐户密码进行联盟管理。You use the member account and member account password for consortium management.
skuNameskuName 层类型。Tier type. 对于标准层,请使用 S0,对于基本层,请使用 B0。Use S0 for Standard and B0 for Basic.

创建区块链成员和支持资源需要大约 10 分钟。It takes about 10 minutes to create the blockchain member and supporting resources.

清理资源Clean up resources

你可以将所创建的区块链成员用于下一快速入门或教程。You can use the blockchain member you created for the next quickstart or tutorial. 不再需要这些资源时,可以通过删除为该快速入门创建的 myResourceGroup 资源组来删除这些资源。When no longer needed, you can delete the resources by deleting the myResourceGroup resource group you created for the quickstart.

运行以下命令来删除资源组和所有相关资源。Run the following command to remove the resource group and all related resources.

az group delete \
                 --name myResourceGroup \
                 --yes

后续步骤Next steps

在本快速入门中,你已部署了一个 Azure 区块链服务成员和一个新的联盟。In this quickstart, you deployed an Azure Blockchain Service member and a new consortium. 请尝试学习下一个快速入门,使用适用于 Ethereum 的 Azure 区块链开发工具包将内容附加到 Azure 区块链服务成员。Try the next quickstart to use Azure Blockchain Development Kit for Ethereum to attach to an Azure Blockchain Service member.