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

使用 Azure 门户配置区块链数据管理器Configure Blockchain Data Manager using the Azure portal

将 Azure 区块链服务的区块链数据管理器配置为捕获区块链数据并将其发送到 Azure 事件网格主题。Configure Blockchain Data Manager for Azure Blockchain Service to capture blockchain data and send it to an Azure Event Grid Topic.

若要配置区块链数据管理器实例,你需要:To configure a Blockchain Data Manager instance, you:

  • 为 Azure 区块链 Service transaction 节点创建区块链数据管理器实例Create a Blockchain Data Manager instance for an Azure Blockchain Service transaction node
  • 添加区块链应用程序Add your blockchain applications

必备组件Prerequisites

创建实例Create instance

区块链数据管理器实例连接并监控 Azure 区块链服务事务节点。A Blockchain Data Manager instance connects and monitors an Azure Blockchain Service transaction node. 只有有权访问事务节点的用户才能创建连接。Only users with access to the transaction node can create a connection. 实例从事务节点捕获所有原始块和原始事务数据。An instance captures all raw block and raw transaction data from the transaction node.

出站连接将区块链数据发送到 Azure 事件网格。An outbound connection sends blockchain data to Azure Event Grid. 创建实例时,可以配置单个出站连接。You configure a single outbound connection when you create the instance. 区块链数据管理器支持对任意给定的区块链数据管理器实例使用多个事件网格主题出站连接。Blockchain Data Manager supports multiple Event Grid Topic outbound connections for any given Blockchain Data Manager instance. 可将区块链数据发送到一个或多个目标。You can send blockchain data to a single destination or send blockchain data to multiple destinations. 若要添加另一个目标,只需向实例添加其他出站连接即可。To add another destination, just add additional outbound connections to the instance.

  1. 登录到 Azure 门户Sign in to the Azure portal.

  2. 请参阅要连接到区块链数据管理器的 Azure 区块链服务成员。Go to the Azure Blockchain Service member you want to connect to Blockchain Data Manager. 选择“区块链数据管理器”。Select Blockchain Data Manager.

  3. 选择 添加Select Add.

    添加“区块链数据管理器”

    输入以下详细信息:Enter the following details:

    设置Setting 描述Description
    名称Name 为连接的区块链数据管理器输入唯一的名称。Enter a unique name for a connected Blockchain Data Manager. 区块链数据管理器名称可以包含小写字母和数字,并且最大长度为20个字符。The Blockchain Data Manager name can contain lower case letters and numbers and has a maximum length of 20 characters.
    事务节点Transaction node 选择事务节点。Choose a transaction node. 仅列出具有读取访问权限的事务节点。Only transaction nodes you have read access are listed.
    连接名称Connection name 输入用于发送区块链事务数据的出站连接的唯一名称。Enter a unique name of the outbound connection where blockchain transaction data is sent.
    事件网格终结点Event grid endpoint 选择与区块链数据管理器实例相同的订阅中的事件网格主题。Choose an event grid topic in the same subscription as the Blockchain Data Manager instance.
  4. 选择“确定”。Select OK.

    创建区块链数据管理器实例需要不到一分钟的时间。It takes less than a minute to create a Blockchain Data Manager instance. 部署实例后,它会自动启动。After the instance is deployed, it is automatically started. 正在运行的区块链数据管理器实例从事务节点捕获区块链事件,并将数据发送到出站连接。A running Blockchain Data Manager instance captures blockchain events from the transaction node and sends data to the outbound connections.

    新实例将出现在 Azure 区块链服务成员的区块链数据管理器实例列表中。The new instance appears in the list of Blockchain Data Manager instances for the Azure Blockchain Service member.

    区块链数据成员实例列表

添加区块链应用程序Add blockchain application

如果添加区块链应用程序,则区块链数据管理器对应用程序的事件和属性状态进行解码。If you add a blockchain application, Blockchain Data Manager decodes event and property state for the application. 否则,只会发送原始块和原始事务数据。Otherwise, only raw block and raw transaction data is sent. 区块链数据管理器还会在部署协定时发现协定地址。Blockchain Data Manager also discovers contract addresses when the contract is deployed. 可以将多个区块链应用程序添加到区块链数据管理器实例。You can add multiple blockchain applications to a Blockchain Data Manager instance.

重要

目前,不完全支持声明密度数组类型映射类型的区块链应用程序。Currently, blockchain applications that declare Solidity array types or mapping types are not fully supported. 声明为数组或映射类型的属性将不会在ContractPropertiesMsgDecodedContractEventsMsg消息中进行解码。Properties declared as array or mapping types will not be decoded in ContractPropertiesMsg or DecodedContractEventsMsg messages.

区块链数据管理器需要智能协定 ABI 并部署了字节码文件来添加应用程序。Blockchain Data Manager requires a smart contract ABI and deployed bytecode file to add the application.

获取协定 ABI 和字节码Get Contract ABI and bytecode

合同 ABI 定义智能合同接口。The contract ABI defines the smart contract interfaces. 其中描述了如何与智能合同交互。It describes how to interact with the smart contract. 可以使用适用于 Ethereum 扩展的 Azure 区块链开发工具包将合同 ABI 复制到剪贴板。You can use the Azure Blockchain Development Kit for Ethereum extension to copy the contract ABI to the clipboard.

  1. 在 Visual Studio Code 资源管理器窗格中,展开 Solidity 项目的 build/contracts 文件夹。In the Visual Studio Code explorer pane, expand the build/contracts folder of your Solidity project.

  2. 右键单击合同元数据 JSON 文件。Right-click the contract metadata JSON file. 文件名为智能合同名称后接 .json 扩展名。The file name is the smart contract name followed by the .json extension.

  3. 选择“复制合同 ABI”。Select Copy Contract ABI.

    选择了“复制合同 ABI”的 Visual Studio Code 窗格

    合同 ABI 将复制到剪贴板。The contract ABI is copied to the clipboard.

  4. 将 abi 数组保存为 JSON 文件。Save the abi array as a JSON file. 例如:abi.json。For example, abi.json. 在稍后的步骤中会使用此文件。You use the file in a later step.

区块链数据管理器需要为智能合同部署的字节码。Blockchain Data Manager requires the deployed bytecode for the smart contract. 部署的字节码不同于智能合同字节码。The deployed bytecode is different than the smart contract bytecode. 使用 Azure 区块链开发工具包扩展将字节码复制到剪贴板。You use the Azure blockchain development kit extension to copy the bytecode to the clipboard.

  1. 在 Visual Studio Code 资源管理器窗格中,展开 Solidity 项目的 build/contracts 文件夹。In the Visual Studio Code explorer pane, expand the build/contracts folder of your Solidity project.

  2. 右键单击合同元数据 JSON 文件。Right-click the contract metadata JSON file. 文件名为智能合同名称后接 .json 扩展名。The file name is the smart contract name followed by the .json extension.

  3. 选择 "复制事务字节码"。Select Copy Transaction Bytecode.

    包含复制事务字节码选择的 Visual Studio Code 窗格

    字节码将被复制到剪贴板。The bytecode is copied to the clipboard.

  4. 将“字节码”值保存为 JSON 文件。Save the bytecode value as a JSON file. 例如:“bytecode.json”。For example, bytecode.json. 在稍后的步骤中会使用此文件。You use the file in a later step.

下面的示例演示的是如何在 VS Code 编辑器中打开“abi.json”和“bytecode.json”。The following example shows abi.json and bytecode.json files open in the VS Code editor. 文件应看起来很相似。Your files should look similar.

abi.json 和 bytecode.json 文件的示例

创建合同 ABI 和字节码 URLCreate contract ABI and bytecode URL

添加应用程序时,区块链数据管理器要求由 URL 访问合同 ABI 和字节码文件。Blockchain Data Manager requires the contract ABI and bytecode files to be accessible by a URL when adding an application. 可以使用 Azure 存储帐户提供可私下访问的 URL。You can use an Azure Storage account to provide a privately accessible URL.

创建存储器帐户Create storage account

若要在 Azure 门户中创建常规用途 v2 存储帐户,请执行以下步骤:To create a general-purpose v2 storage account in the Azure portal, follow these steps:

  1. 在 Azure 门户菜单中,选择“所有服务” 。On the Azure portal menu, select All services. 在资源列表中,键入“存储帐户” 。In the list of resources, type Storage Accounts. 开始键入时,会根据输入筛选该列表。As you begin typing, the list filters based on your input. 选择“存储帐户” 。Select Storage Accounts.

  2. 在显示的“存储帐户”窗口中,选择“添加”。 On the Storage Accounts window that appears, choose Add.

  3. 选择要在其中创建存储帐户的订阅。Select the subscription in which to create the storage account.

  4. 在“资源组” 字段下,选择“新建” 。Under the Resource group field, select Create new. 输入新资源组的名称,如下图中所示。Enter a name for your new resource group, as shown in the following image.

    显示如何在门户中创建资源组的屏幕截图

  5. 然后,输入存储帐户的名称。Next, enter a name for your storage account. 所选名称在 Azure 中必须唯一。The name you choose must be unique across Azure. 该名称还必须为 3 到 24 个字符,并且只能包含数字和小写字母。The name also must be between 3 and 24 characters in length, and can include numbers and lowercase letters only.

  6. 选择存储帐户的位置或使用默认位置。Select a location for your storage account, or use the default location.

  7. 将这些字段设置为其默认值:Leave these fields set to their default values:

    字段Field Value
    部署模型Deployment model 资源管理器Resource Manager
    性能Performance 标准Standard
    帐户类型Account kind StorageV2(常规用途 v2)StorageV2 (general-purpose v2)
    复制Replication 读取访问异地冗余存储 (RA-GRS)Read-access geo-redundant storage (RA-GRS)
    访问层Access tier Hot
  8. 选择“查看+创建” 可查看存储帐户设置并创建帐户。Select Review + Create to review your storage account settings and create the account.

  9. 选择“创建” 。Select Create.

有关存储帐户类型和其他存储帐户设置的详细信息,请参阅 Azure 存储帐户概述For more information about types of storage accounts and other storage account settings, see Azure storage account overview. 有关资源组的详细信息,请参阅 Azure 资源管理器概述For more information on resource groups, see Azure Resource Manager overview.

上传合同文件Upload contract files

  1. 为存储帐户新建容器。Create a new container for the storage account. 选择“容器”>“容器”。Select Containers > Container.

    创建存储帐户容器

    字段Field 描述Description
    名称Name 为该容器命名。Name the container. 例如,“smartcontract”For example, smartcontract
    公共访问级别Public access level 选择“专用(没有匿名访问权限)”Choose Private (no anonymous access)
  2. 选择“确定”创建容器。Select OK to create the container.

  3. 先选择该容器,然后选择“上传”。Select the container then select Upload.

  4. 选择在获取合同 ABI 和字节码部分中创建的两个 JSON 文件。Choose both JSON files you created in the Get Contract ABI and bytecode section.

    上传 blob

    选择“上传”。Select Upload.

生成 URLGenerate URL

对于各个 blob,生成共享访问签名。For each blob, generate a shared access signature.

  1. 选择“ABI JSON blob”。Select the ABI JSON blob.

  2. 选择“生成 SAS”Select Generate SAS

  3. 设置所需的访问签名到期时间,然后选择“生成 blob SAS 令牌和 URL”。Set desired access signature expiration then select Generate blob SAS token and URL.

    生成 SAS 令牌

  4. 复制“Blob SAS URL”,以便在下一部分使用。Copy the Blob SAS URL and save it for the next section.

  5. 重复字节码 JSON blob 的生成 URL 步骤。Repeat the Generate URL steps for the bytecode JSON blob.

向实例添加应用程序Add application to instance

  1. 从实例列表中选择区块链数据管理器实例。Select your Blockchain Data Manager instance from the instance list.

  2. 选择“区块链应用程序”。Select Blockchain applications.

  3. 选择 添加Select Add.

    添加区块链应用程序

    输入区块链应用程序的名称以及智能合同 ABI 和字节码 URL。Enter the name of the blockchain application and the smart contract ABI and bytecode URLs.

    设置Setting 描述Description
    名称Name 输入要跟踪的区块链应用程序的唯一名称。Enter a unique name for the blockchain application to track.
    合同 ABIContract ABI 合同 ABI 文件的 URL 路径。URL path to the Contract ABI file. 有关详细信息,请参阅创建合同 ABI 和字节码 URLFor more information, see Create contract ABI and bytecode URL.
    合同字节码Contract Bytecode 字节码文件的 URL 路径。URL path to bytecode file. 有关详细信息,请参阅创建合同 ABI 和字节码 URLFor more information, see Create contract ABI and bytecode URL.
  4. 选择“确定”。Select OK.

    创建应用程序后,应用程序将显示在区块链应用程序的列表中。Once the application is created, the application appears in the list of blockchain applications.

    区块链应用程序列表

可以删除 Azure 存储帐户,也可以使用它来配置更多区块链应用程序。You can delete the Azure Storage account or use it to configure more blockchain applications. 如果要删除 Azure 存储帐户,可以删除该资源组。If you wish to delete the Azure Storage account, you can delete the resource group. 删除资源组也会删除相关联的存储帐户,以及与资源组相关联的任何其他资源。Deleting the resource group also deletes the associated storage account, and any other resources associated with the resource group.

停止实例Stop instance

要停止捕获区块链事件并将数据发送到出站连接时,请停止区块链 Manager 实例。Stop the Blockchain Manager instance when you want to stop capturing blockchain events and sending data to the outbound connections. 实例停止后,区块链数据管理器不会产生费用。When the instance is stopped, no charges are incurred for Blockchain Data Manager. 有关详细信息,请参阅定价For more information, see pricing.

  1. 请参阅 "概述" 并选择 "停止"。Go to Overview and select Stop.

    停止实例

后续步骤Next steps

尝试下一教程使用区块链数据管理器和 Azure Cosmos DB 创建区块链事务消息资源管理器。Try the next tutorial creating a blockchain transaction message explorer using Blockchain Data Manager and Azure Cosmos DB.