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

教程:使用区块链数据管理器向 Azure Cosmos DB 发送数据Tutorial: Use Blockchain Data Manager to send data to Azure Cosmos DB

在本教程中,将区块链数据管理器用于 Azure 区块链服务,以便在 Azure Cosmos DB 中记录区块链事务数据。In this tutorial, you use Blockchain Data Manager for Azure Blockchain Service to record blockchain transaction data in Azure Cosmos DB. 区块链数据管理器捕获、转换区块链账本数据并将其传送到 Azure 事件网格主题。Blockchain Data Manager captures, transforms, and delivers blockchain ledger data to Azure Event Grid Topics. 通过 Azure 事件网格,可以使用 Azure 逻辑应用连接器在 Azure Cosmos DB 数据库中创建文档。From Azure Event Grid, you use a Azure Logic App connector to create documents in an Azure Cosmos DB database. 完成教程后,可以在 Azure Cosmos DB 数据资源管理器中浏览区块链事务数据。When finished with tutorial, you can explore blockchain transaction data in Azure Cosmos DB Data Explorer.

区块链事务详细信息Blockchain transaction detail

本教程介绍以下操作:In this tutorial, you:

  • 创建区块链数据管理器实例Create a Blockchain Data Manager instance
  • 添加区块链应用程序以解码事务属性和事件Add a blockchain application to decode transaction properties and events
  • 创建 Azure Cosmos DB 帐户和数据库来存储事务数据Create an Azure Cosmos DB account and database to store transaction data
  • 创建 Azure 逻辑应用,将 Azure 事件网格主题连接到 Azure Cosmos DBCreate an Azure Logic App to connect an Azure Event Grid Topic to Azure Cosmos DB
  • 将事务发送到区块链账本Send a transaction to a blockchain ledger
  • 查看 Azure Cosmos DB 中的已解码事务数据View the decoded transaction data in Azure Cosmos DB

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

先决条件Prerequisites

创建实例Create instance

区块链数据管理器实例连接并监控 Azure 区块链服务事务节点。A Blockchain Data Manager instance connects and monitors an Azure Blockchain Service transaction node. 实例从事务节点捕获所有原始块和原始事务数据。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.

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

  2. 转到在先决条件快速入门:使用 Azure 门户创建区块链成员中创建的 Azure 区块链服务成员。Go to the Azure Blockchain Service member you created in the prerequisite Quickstart: Create a blockchain member using the Azure portal. 选择“区块链数据管理器” 。Select Blockchain Data Manager.

  3. 选择 添加Select Add.

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

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

    设置Setting 示例Example 说明Description
    名称Name mywatchermywatcher 为连接的区块链数据管理器输入唯一的名称。Enter a unique name for a connected Blockchain Data Manager.
    事务节点Transaction node myblockchainmembermyblockchainmember 选择在先决条件中创建的 Azure 区块链服务成员的默认事务节点。Choose the default transaction node of the Azure Blockchain Service member you created in the prerequisite.
    连接名称Connection name cosmosdbcosmosdb 输入用于发送区块链事务数据的出站连接的唯一名称。Enter a unique name of the outbound connection where blockchain transaction data is sent.
    事件网格终结点Event grid endpoint myTopicmyTopic 选择在先决条件中创建的事件网格主题。Choose an event grid topic you created in the prerequisite. 注意:区块链数据管理器实例和事件网格主题必须位于同一订阅中。Note: The Blockchain Data Manager instance and the event grid topic must be in the same subscription.
  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 event grid.

添加应用程序Add application

添加“helloblockchain” 区块链应用程序,以便区块链数据管理器解码事件和属性状态。Add the helloblockchain blockchain application so that Blockchain Data Manager decodes event and property state. 区块链数据管理器需要智能合同 ABI 和字节码文件来添加应用程序。Blockchain Data Manager requires the smart contract ABI and 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 资源管理器”窗格中,展开在先决条件教程: 使用 Visual Studio Code 创建、生成和部署智能合同中创建的“helloblockchain”Solidity 项目的“生成/合同”文件夹。In the Visual Studio Code explorer pane, expand the build/contracts folder of the helloblockchain Solidity project you created in the prerequisite Tutorial: Use Visual Studio Code to create, build, and deploy smart contracts.

  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 StandardStandard
    帐户类型Account kind StorageV2(常规用途 v2)StorageV2 (general-purpose v2)
    复制Replication 读取访问异地冗余存储 (RA-GRS)Read-access geo-redundant storage (RA-GRS)
    访问层Access tier Hot
  8. 如果计划使用 Azure Data Lake Storage,请选择“高级” 选项卡,然后将“分层命名空间” 设置为“启用” 。If you plan to use Azure Data Lake Storage, choose the Advanced tab, and then set Hierarchical namespace to Enabled.

  9. 选择“查看+创建” 可查看存储帐户设置并创建帐户。Select Review + Create to review your storage account settings and create the account.

  10. 选择“创建” 。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.

    创建存储帐户容器

    设置Setting 说明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.

将 helloblockchain 应用程序添加到实例Add helloblockchain 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.

创建 Azure Cosmos DBCreate Azure Cosmos DB

  1. 转到 Azure 门户以创建 Azure Cosmos DB 帐户。Go to the Azure portal to create an Azure Cosmos DB account. 搜索“Azure Cosmos DB”,然后选择它。 。Search for and select Azure Cosmos DB.

    Azure 门户“数据库”窗格

  2. 选择 添加Select Add.

  3. 在“创建 Azure Cosmos DB 帐户”页上,输入新 Azure Cosmos 帐户的基本设置 。On the Create Azure Cosmos DB Account page, enter the basic settings for the new Azure Cosmos account.

    设置Setting Value 说明Description
    订阅Subscription 订阅名称Subscription name 选择要用于此 Azure Cosmos 帐户的 Azure 订阅。Select the Azure subscription that you want to use for this Azure Cosmos account.
    资源组Resource Group 资源组名称Resource group name 选择一个资源组,或者选择“新建”,然后输入新资源组的唯一名称。 Select a resource group, or select Create new, then enter a unique name for the new resource group.
    帐户名Account Name 唯一的名称A unique name 输入标识此 Azure Cosmos 帐户的名称。Enter a name to identify your Azure Cosmos account. 由于 documents.azure.com 将追加到所提供的名称以创建 URI,因此,请使用唯一的名称 。Because documents.azure.com is appended to the name that you provide to create your URI, use a unique name.

    名称只能包含小写字母、数字和连字符 (-)。The name can only contain lowercase letters, numbers, and the hyphen (-) character. 它的长度必须介于 3 到 31 个字符之间。It must be between 3-31 characters in length.
    APIAPI 要创建的帐户的类型The type of account to create 选择“Core (SQL)”,以便使用 SQL 语法创建文档数据库并进行查询 。Select Core (SQL) to create a document database and query by using SQL syntax.

    API 确定要创建的帐户的类型。The API determines the type of account to create. Azure Cosmos DB 提供五种 API:适用于文档数据的 Core (SQL) 和 MongoDB、适用于图形数据的 Gremlin、Azure 表和 Cassandra。Azure Cosmos DB provides five APIs: Core (SQL) and MongoDB for document data, Gremlin for graph data, Azure Table, and Cassandra. 目前,你必须为每种 API 创建单独的帐户。Currently, you must create a separate account for each API.

    详细了解 SQL APILearn more about the SQL API.
    位置Location 离用户最近的区域The region closest to your users 选择用于托管 Azure Cosmos DB 帐户的地理位置。Select a geographic location to host your Azure Cosmos DB account. 使用离用户最近的位置,使他们能够以最快的速度访问数据。Use the location that is closest to your users to give them the fastest access to the data.

    Azure Cosmos DB 的“新建帐户”页

  4. 选择“查看 + 创建” 。Select Review + create. 可以跳过“网络”和“标记”部分 。You can skip the Network and Tags sections.

  5. 检查帐户设置,然后选择“创建”。 Review the account settings, and then select Create. 创建帐户需要几分钟时间。It takes a few minutes to create the account. 等待门户页显示“你的部署已完成” 消息。Wait for the portal page to display Your deployment is complete.

    Azure 门户“通知”窗格

  6. 选择“转到资源”,转到 Azure Cosmos DB 帐户页。 Select Go to resource to go to the Azure Cosmos DB account page.

    Azure Cosmos DB 帐户页

添加数据库和容器Add a database and container

可以使用 Azure 门户中的数据资源管理器来创建数据库和容器。You can use the Data Explorer in the Azure portal to create a database and container.

  1. 在 Azure Cosmos DB 帐户页上的左侧导航栏中选择“数据资源管理器”,然后选择“新建容器”。 Select Data Explorer from the left navigation on your Azure Cosmos DB account page, and then select New Container.

  2. 在“添加容器”窗格中,输入新容器的设置。 In the Add container pane, enter the settings for the new container.

    添加容器设置

    设置Setting 说明Description
    数据库 IDDatabase ID 输入“blockchain-data” 作为新数据库的名称。Enter blockchain-data as the name for the new database.
    吞吐量Throughput 将吞吐量保留为每秒 400 个请求单位 (RU/s)。Leave the throughput at 400 request units per second (RU/s). 如果想要减少延迟,以后可以增加吞吐量。If you want to reduce latency, you can scale up the throughput later.
    容器 IDContainer ID 输入“Messages” 作为新容器的名称。Enter Messages as the name for your new container.
    分区键Partition key 使用“/MessageType” 作为分区键。Use /MessageType as the partition key.
  3. 选择“确定” 。Select OK. 数据资源管理器将显示新建的数据库和容器。The Data Explorer displays the new database and the container that you created.

创建逻辑应用Create Logic App

需要集成系统和服务时,Azure 逻辑应用可帮助你计划和自动化业务流程和工作流。Azure Logic Apps helps you schedule and automate business processes and workflows when you need to integrate systems and services. 可以使用逻辑应用将事件网格连接到 Azure Cosmos DB。You can use a logic app to connect Event Grid to Azure Cosmos DB.

  1. Azure 门户中,选择“创建资源” > “集成” > “逻辑应用” 。In the Azure portal, select Create a resource > Integration > Logic App.

  2. 提供有关在何处创建逻辑应用的详细信息。Provide details on where to create your logic app. 完成后,选择“创建” 。After you're done, select Create.

    有关创建逻辑应用的详细信息,请参阅使用 Azure 逻辑应用创建自动化工作流For more information on creating logic apps, see Create automated workflows with Azure Logic Apps.

  3. 在 Azure 部署你的应用后,请选择你的逻辑应用资源。After Azure deploys your app, select your logic app resource.

  4. 在逻辑应用设计器中的“模板”下,选择“空白逻辑应用”。 In the Logic Apps Designer, under Templates, select Blank Logic App.

添加事件网格触发器Add Event Grid trigger

每个逻辑应用都必须从触发器开始,该触发器在发生特定事件或特定条件得到满足的情况下触发。Every logic app must start with a trigger, which fires when a specific event happens or when a specific condition is met. 每当触发器触发时,逻辑应用引擎就会创建一个逻辑应用实例来启动并运行工作流。Each time the trigger fires, the Logic Apps engine creates a logic app instance that starts and runs your workflow. 使用 Azure 事件网格触发器将区块链事务数据从事件网格发送到 Cosmos DB。Use an Azure Event Grid trigger to sends blockchain transaction data from Event Grid to Cosmos DB.

  1. 在逻辑应用设计器中,搜索并选择“Azure 事件网格” 连接器。In the Logic Apps Designer, search for and select the Azure Event Grid connector.

  2. 从“触发器” 选项卡中,选择“当资源事件发生时” 。From the Triggers tab, select When a resource event occurs.

  3. 创建与事件网格主题的 API 连接。Create an API connection to your Event Grid Topic.

    事件网格触发器设置

    设置Setting 说明Description
    订阅Subscription 选择包含事件网格主题的订阅。Choose the subscription that contains the Event Grid Topic.
    资源类型Resource Type 选择“Microsoft.EventGrid.Topics” 。Choose Microsoft.EventGrid.Topics.
    资源名称Resource Name 选择区块链数据管理器向其发送事务数据消息的事件网格主题的名称。Choose the name of the Event Grid Topic where Blockchain Data Manager is sending transaction data messages.

添加 Cosmos DB 操作Add Cosmos DB action

添加操作以在每个事务的 Cosmos DB 中创建文档。Add an action to create a document in Cosmos DB for each transaction. 使用事务消息类型作为分区键以便对消息进行分类。Use the transaction message type as the partition key to categorize the messages.

  1. 选择“新建步骤”。 Select New step.

  2. 在“选择操作” 上,搜索“Azure Cosmos DB” 。On Choose an action, search for Azure Cosmos DB.

  3. 选择“Azure Cosmos DB”>“操作”>“创建或更新文档” 。Choose Azure Cosmos DB > Actions > Create or update document.

  4. 创建与 Cosmos DB 数据库的 API 连接。Create an API connection to your Cosmos DB database.

    Cosmos DB 连接设置

    设置Setting 说明Description
    连接名称Connection Name 选择包含事件网格主题的订阅。Choose the subscription that contains the Event Grid Topic.
    DocumentDB 帐户DocumentDB Account 选择在创建 Azure Cosmos DB 帐户部分中创建的 DocumentDB 帐户。Choose the DocumentDB account you created in the Create Azure Cosmos DB account section.
  5. 输入先前在添加数据库和容器部分中创建的 Azure Cosmos DB 的“数据库 ID” 和“集合 ID” 。Enter the Database ID and Collection ID for your Azure Cosmos DB that you created previously in the Add a database and container section.

  6. 选择“文档”设置 。Select the Document setting. 在“添加动态内容” 弹出窗口中,选择“表达式” ,然后复制并粘贴以下表达式:In the Add dynamic content pop-out, select Expression and copy and paste the following expression:

    addProperty(triggerBody()?['data'], 'id', utcNow())
    

    表达式将获取消息的数据部分,并将 ID 设置为时间戳值。The expression gets the data portion of the message and sets the ID to a timestamp value.

  7. 选择“添加新参数” 并选择“分区键值” 。Select Add new parameter and choose Partition key value.

  8. 将“分区键值” 设为 "@{triggerBody()['data']['MessageType']}"Set the Partition key value to "@{triggerBody()['data']['MessageType']}". 该值必须用双引号括起来。The value must be surrounded by double quotes.

    具有 Cosmos DB 设置的逻辑应用设计器

    该值将分区键设置为事务消息类型。The value sets the partition key to the transaction message type.

  9. 选择“保存”。 Select Save.

逻辑应用监视事件网格主题。The logic app monitors the Event Grid Topic. 当从区块链数据管理器发送新的事务消息时,逻辑应用会在 Cosmos DB 中创建一个文档。When a new transaction message is sent from Blockchain Data Manager, the logic app creates a document in Cosmos DB.

发送事务Send a transaction

接下来,将事务发送到区块链账本以测试所创建的内容。Next, send a transaction to the blockchain ledger to test what you created. 使用在先决条件教程: 使用 Visual Studio Code 创建、生成和部署智能合同中创建的“sendrequest.js”脚本。Use the sendrequest.js script you created in the prerequisite Tutorial: Use Visual Studio Code to create, build, and deploy smart contracts.

在 VS Code 的终端窗格中,使用 Truffle 针对联盟区块链网络执行该脚本。In VS Code's terminal pane, use Truffle to execute the script on your consortium blockchain network. 在终端窗格菜单栏中选择“终端”选项卡,并从下拉列表中选择“PowerShell”。 In the terminal pane menu bar, select the Terminal tab and PowerShell in the dropdown.

truffle exec sendrequest.js --network <blockchain network>

将 <blockchain network> 替换为 truffle-config.js 中定义的区块链网络名称。Replace <blockchain network> with the name of the blockchain network defined in the truffle-config.js.

添加事务

查看事务数据View transaction data

现在,你已将区块链数据管理器连接到 Azure Cosmos DB,你可以在 Cosmos DB 数据资源管理器中查看区块链事务消息。Now that you have connected your Blockchain Data Manager to Azure Cosmos DB, you can view the blockchain transaction messages in Cosmos DB Data Explorer.

  1. 转到 Cosmos DB 数据资源管理器视图。Go to the Cosmos DB Data Explorer view. 例如,“cosmosdb-blockchain”>“数据资源管理器”>“区块链-数据”>“消息”>“项目” 。For example, cosmosdb-blockchain > Data Explorer > blockchain-data > Messages > Items.

    Cosmos DB 数据资源管理器

    数据资源管理器列出在 Cosmos DB 数据库中创建的区块链数据消息。Data Explorer lists the blockchain data messages that were created in the Cosmos DB database.

  2. 通过选择“项 ID”浏览消息,并查找具有匹配事务哈希的消息。Browse through the messages by selecting item ID and find the message with the matching transaction hash.

    区块链事务详细信息Blockchain transaction detail

    原始事务消息包含有关该事务的详细信息。The raw transaction message contains detail about the transaction. 但是,属性信息已加密。However, the property information is encrypted.

    由于已将 HelloBlockchain 智能合同添加到区块链数据管理器实例,因此还会发送“ContractProperties” 消息类型,其中包含已解码的属性信息。Since you added the HelloBlockchain smart contract to the Blockchain Data Manager instance, a ContractProperties message type is also sent that contains decoded property information.

  3. 为事务查找“ContractProperties” 消息。Find the ContractProperties message for the transaction. 它应该是列表中的下一条消息。It should be the next message in the list.

    区块链事务详细信息Blockchain transaction detail

    DecodedProperties 数组包含事务的属性。The DecodedProperties array contains the properties of the transaction.

祝贺你!Congratulations! 已成功使用区块链数据管理器和 Azure Cosmos DB 创建事务消息资源管理器。You have successfully created a transaction message explorer using Blockchain Data Manager and Azure Cosmos DB.

清理资源Clean up resources

当不再需要时,可以删除用于本教程的资源和资源组。When no longer needed, you can delete the resources and resource groups you used for this tutorial. 删除资源组的步骤:To delete a resource group:

  1. 在 Azure 门户中,导航至左侧导航窗格中的“资源组” ,然后选择要删除的资源组。In the Azure portal, navigate to Resource group in the left navigation pane and select the resource group you want to delete.
  2. 选择“删除资源组” 。Select Delete resource group. 输入资源组名称确认删除并选择“删除” 。Verify deletion by entering the resource group name and select Delete.

后续步骤Next steps

详细了解如何与区块链账本集成。Learn more about integrating with blockchain ledgers.