你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
ConfidentialLedgerClient.GetLedgerEntryAsync 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
[协议方法]获取指定事务 ID 处的账本条目。可以选择指定集合 ID 以指示从中获取值的集合。
- 此 协议方法 允许显式创建请求并处理高级方案的响应。
public virtual System.Threading.Tasks.Task<Azure.Response> GetLedgerEntryAsync (string transactionId, string collectionId = default, Azure.RequestContext context = default);
abstract member GetLedgerEntryAsync : string * string * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Response>
override this.GetLedgerEntryAsync : string * string * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Response>
Public Overridable Function GetLedgerEntryAsync (transactionId As String, Optional collectionId As String = Nothing, Optional context As RequestContext = Nothing) As Task(Of Response)
参数
- transactionId
- String
标识写入事务。
- collectionId
- String
集合 ID。
- context
- RequestContext
请求上下文,可以基于每个调用替代客户端管道的默认行为。
返回
从服务返回的响应。
例外
transactionId
为 null。
transactionId
是一个空字符串,预期为非空。
服务返回了非成功状态代码。
示例
此示例演示如何使用所需的参数调用 GetLedgerEntryAsync 并分析结果。
var credential = new DefaultAzureCredential();
var endpoint = new Uri("<https://my-service.azure.com>");
var client = new ConfidentialLedgerClient(endpoint, credential);
Response response = await client.GetLedgerEntryAsync("<transactionId>");
JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("state").ToString());
此示例演示如何使用所有参数调用 GetLedgerEntryAsync,以及如何分析结果。
var credential = new DefaultAzureCredential();
var endpoint = new Uri("<https://my-service.azure.com>");
var client = new ConfidentialLedgerClient(endpoint, credential);
Response response = await client.GetLedgerEntryAsync("<transactionId>", "<collectionId>");
JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("state").ToString());
Console.WriteLine(result.GetProperty("entry").GetProperty("contents").ToString());
Console.WriteLine(result.GetProperty("entry").GetProperty("collectionId").ToString());
Console.WriteLine(result.GetProperty("entry").GetProperty("transactionId").ToString());
注解
若要返回较旧的账本条目,必须从磁盘读取账本的相关部分并对其进行验证。 为了防止在 enclave 内阻塞,响应将指示条目是否已就绪以及响应的一部分,或者加载是否仍在进行。
下面是响应有效负载的 JSON 架构。
响应正文:
的 LedgerQueryResult
架构:
{
state: "Loading" | "Ready", # Required. State of a ledger query.
entry: {
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.
}, # Optional. The ledger entry found as a result of the query. This is only available if the query is in Ready state.
}