你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

ConfidentialLedgerClient.GetCurrentLedgerEntry(String, RequestContext) 方法

定义

[协议方法]获取账本中可用的当前值。

  • 协议方法 允许显式创建请求并处理高级方案的响应。
public virtual Azure.Response GetCurrentLedgerEntry (string collectionId = default, Azure.RequestContext context = default);
abstract member GetCurrentLedgerEntry : string * Azure.RequestContext -> Azure.Response
override this.GetCurrentLedgerEntry : string * Azure.RequestContext -> Azure.Response
Public Overridable Function GetCurrentLedgerEntry (Optional collectionId As String = Nothing, Optional context As RequestContext = Nothing) As Response

参数

collectionId
String

集合 ID。

context
RequestContext

请求上下文,它可以基于每个调用替代客户端管道的默认行为。

返回

从服务返回的响应。

例外

服务返回了不成功状态代码。

示例

此示例演示如何调用 GetCurrentLedgerEntry 并分析结果。

var credential = new DefaultAzureCredential();
var endpoint = new Uri("<https://my-service.azure.com>");
var client = new ConfidentialLedgerClient(endpoint, credential);

Response response = client.GetCurrentLedgerEntry();

JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("contents").ToString());

此示例演示如何使用所有参数调用 GetCurrentLedgerEntry,以及如何分析结果。

var credential = new DefaultAzureCredential();
var endpoint = new Uri("<https://my-service.azure.com>");
var client = new ConfidentialLedgerClient(endpoint, credential);

Response response = client.GetCurrentLedgerEntry("<collectionId>");

JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("contents").ToString());
Console.WriteLine(result.GetProperty("collectionId").ToString());
Console.WriteLine(result.GetProperty("transactionId").ToString());

注解

可以选择指定集合 ID。

下面是响应有效负载的 JSON 架构。

响应正文:

LedgerEntry架构:

{
  contents: string, # Required. Contents of the ledger entry.
  collectionId: string, # Optional.
  transactionId: string, # Optional. A unique identifier for the state of the ledger. If returned as part of a LedgerEntry, it indicates the state from which the entry was read.
}

适用于