Share via


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

Database.ReadThroughputAsync 方法

定义

重载

ReadThroughputAsync(CancellationToken)

获取数据库吞吐量,以度量 Azure Cosmos 服务中的每秒请求单位数。

ReadThroughputAsync(RequestOptions, CancellationToken)

获取数据库吞吐量,以度量 Azure Cosmos 服务中的每秒请求单位数。

ReadThroughputAsync(CancellationToken)

获取数据库吞吐量,以度量 Azure Cosmos 服务中的每秒请求单位数。

public abstract System.Threading.Tasks.Task<int?> ReadThroughputAsync (System.Threading.CancellationToken cancellationToken = default);
abstract member ReadThroughputAsync : System.Threading.CancellationToken -> System.Threading.Tasks.Task<Nullable<int>>
Public MustOverride Function ReadThroughputAsync (Optional cancellationToken As CancellationToken = Nothing) As Task(Of Nullable(Of Integer))

参数

cancellationToken
CancellationToken

(表示请求取消的可选) CancellationToken

返回

预配吞吐量(以每秒请求单位为单位)

示例

以下示例演示如何获取数据库吞吐量。

int? throughput = await database.ReadThroughputAsync();

注解

Null 值表示数据库未预配吞吐量。

适用于

ReadThroughputAsync(RequestOptions, CancellationToken)

获取数据库吞吐量,以度量 Azure Cosmos 服务中的每秒请求单位数。

public abstract System.Threading.Tasks.Task<Microsoft.Azure.Cosmos.ThroughputResponse> ReadThroughputAsync (Microsoft.Azure.Cosmos.RequestOptions requestOptions, System.Threading.CancellationToken cancellationToken = default);
abstract member ReadThroughputAsync : Microsoft.Azure.Cosmos.RequestOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Microsoft.Azure.Cosmos.ThroughputResponse>
Public MustOverride Function ReadThroughputAsync (requestOptions As RequestOptions, Optional cancellationToken As CancellationToken = Nothing) As Task(Of ThroughputResponse)

参数

requestOptions
RequestOptions

吞吐量请求的选项。

cancellationToken
CancellationToken

(表示请求取消的可选) CancellationToken

返回

吞吐量响应。

例外

此异常可以封装许多不同类型的错误。 若要确定特定错误,请始终查看 StatusCode 属性。 读取客户端加密密钥时可能会获取的一些常见代码包括:

StatusCode异常原因
404 NotFound - 这意味着数据库不存在或未分配任何吞吐量。

示例

以下示例演示如何获取吞吐量

 RequestOptions requestOptions = new RequestOptions();
ThroughputProperties throughputProperties = await database.ReadThroughputAsync(requestOptions);
Console.WriteLine($"Throughput: {throughputProperties?.Throughput}");

以下示例演示如何获取吞吐量 MinThroughput,并正在替换

RequestOptions requestOptions = new RequestOptions();
ThroughputResponse response = await database.ReadThroughputAsync(requestOptions);
Console.WriteLine($"Throughput: {response.Resource?.Throughput}");
Console.WriteLine($"MinThroughput: {response.MinThroughput}");
Console.WriteLine($"IsReplacePending: {response.IsReplacePending}");

注解

Null 值表示数据库未预配吞吐量。

适用于