Azure Cosmos DB 无服务器(预览版)Azure Cosmos DB serverless (Preview)


Azure Cosmos DB 无服务器目前处于预览状态。Azure Cosmos DB serverless is currently in preview. 此预览版不附带服务级别协议,我们不建议将其用于生产工作负荷。This preview version is provided without a Service Level Agreement and is not recommended for production workloads. 有关详细信息,请参阅适用于 Azure 预览版的补充使用条款For more information, see Supplemental terms of use for Azure previews.

Azure Cosmos DB 无服务器让你以一种基于消耗的方式使用 Azure Cosmos 帐户,在这种方式下,你只需为数据库操作所消耗的请求单位和数据所消耗的存储空间付费。Azure Cosmos DB serverless lets you use your Azure Cosmos account in a consumption-based fashion where you are only charged for the Request Units consumed by your database operations and the storage consumed by your data. 在无服务器模式下使用 Azure Cosmos DB 时不涉及最低费用。There is no minimum charge involved when using Azure Cosmos DB in serverless mode.


你是否有任何关于无服务器的反馈?Do you have any feedback about serverless? 我们想听一听!We want to hear it! 可以随意向 Azure Cosmos DB 无服务器团队发送消息 free to drop a message to the Azure Cosmos DB serverless team:

使用 Azure Cosmos DB 时,每个数据库操作都具有成本,以请求单位进行表示。When using Azure Cosmos DB, every database operation has a cost expressed in Request Units. 此成本的收费方式取决于你使用的 Azure Cosmos 帐户的类型:How you are charged for this cost depends on the type of Azure Cosmos account you are using:

  • 预配吞吐量模式下,你必须承诺在数据库和容器上预配的特定吞吐量(以每秒请求单位数进行表示)。In provisioned throughput mode, you have to commit to a certain amount of throughput (expressed in Request Units per second) that is provisioned on your databases and containers. 随后从每秒可用的请求单位数中扣除数据库操作的成本。The cost of your database operations is then deducted from the number of Request Units available every second. 在计费周期结束时,会针对你预配的吞吐量进行计费。At the end of your billing period, you get billed for the amount of throughput you have provisioned.
  • 在无服务器模式下,无需在 Azure Cosmos 帐户中创建容器时预配任何吞吐量。In serverless mode, you don't have to provision any throughput when creating containers in your Azure Cosmos account. 在计费周期结束时,会针对你的数据库操作已使用的请求单位数进行计费。At the end of your billing period, you get billed for the number of Request Units that were consumed by your database operations.


Azure Cosmos DB 无服务器最适合你预计会出现以下情况的方案:Azure Cosmos DB serverless best fits scenarios where you expect:

  • 低流量:因为在这类情况下预配容量不是必需的,并且可能会导致成本高昂Light traffic: Because provisioning capacity in such situations isn't required and may be cost-prohibitive
  • 中等突发性:因为无服务器容器每秒最多可提供 5,000 个请求单位Moderate burstability: Because serverless containers can deliver up to 5,000 Request Units per second
  • 中等性能:因为无服务器容器具有特定性能特征Moderate performance: Because serverless containers have specific performance characteristics

出于这些原因,对于以下类型的工作负荷,应考虑使用 Azure Cosmos DB 无服务器:For these reasons, Azure Cosmos DB serverless should be considered for the following types of workload:

  • 开发Development
  • 测试Testing
  • 原型制作Prototyping
  • 概念证明Proof of concept
  • 具有低流量的非关键应用程序Non-critical application with light traffic

有关如何选择最适合于用例的产品/服务的详细指南,请参阅如何在预配吞吐量与无服务器之间进行选择See the how to choose between provisioned throughput and serverless article for more guidance on how to choose the offer that best fits your use-case.

使用无服务器资源Using serverless resources

无服务器是一种新的 Azure Cosmos 帐户类型,这意味着在创建新帐户时,必须在预配吞吐量与无服务器之间进行选择 。Serverless is a new Azure Cosmos account type, which means that you have to choose between provisioned throughput and serverless when creating a new account. 必须创建新的无服务器帐户,才能开始使用无服务器。You must create a new serverless account to get started with serverless. 在预览版期间,创建新的无服务器帐户的唯一受支持方法是使用 Azure 门户During the preview release, the only supported way to create a new serverless account is by using the Azure portal. 当前不支持从/向无服务器模式迁移现有帐户。Migrating existing accounts to/from serverless mode is not currently supported.


目前只有 Azure Cosmos DB 核心 (SQL) API 支持无服务器。Serverless is currently supported on the Azure Cosmos DB Core (SQL) API only.

任何在无服务器帐户中创建的容器都是无服务器容器。Any container that is created in a serverless account is a serverless container. 无服务器容器公开的功能与在预配吞吐量模式下创建的容器相同,因此可以通过完全相同的方式读取、写入和查询数据。Serverless containers expose the same capabilities as containers created in provisioned throughput mode, so you read, write and query your data the exact same way. 不过,无服务器帐户和容器还具有特定特征:However serverless accounts and containers also have specific characteristics:


当无服务器正式发布时,其中一些限制可能会被删除,你的反馈将有助于我们做出决定!Some of these limitations may be eased or removed when serverless becomes generally available and your feedback will help us decide! 请与我们联系并告诉我们有关无服务器体验的详细信息 out and tell us more about your serverless experience:

  • 无服务器帐户只能在单个 Azure 区域中运行。A serverless account can only run in a single Azure region. 创建无服务器帐户之后,不能向该帐户添加其他 Azure 区域。It is not possible to add additional Azure regions to a serverless account after you create it.
  • 不能对无服务器帐户启用 Synapse Link 预览功能It is not possible to enable the Synapse Link preview feature on a serverless account.
  • 无服务器容器不需要预配吞吐量,因此以下陈述适用于这种容器:Provisioning throughput is not required on serverless containers, so the following statements are applicable:
    • 创建无服务器容器时,不能传递任何吞吐量,否则会返回错误。You can't pass any throughput when creating a serverless container and doing so returns an error.
    • 不能读取或更新无服务器容器的吞吐量,否则会返回错误。You can't read or update the throughput on a serverless container and doing so returns an error.
    • 不能在无服务器帐户中创建共享吞吐量数据库,否则会返回错误。You can't create a shared throughput database in a serverless account and doing so returns an error.
  • 无服务器容器可以提供的最大突发吞吐量为每秒 5,000 个请求单位。Serverless containers can deliver a maximum throughput burstability of 5,000 Request Units per second.
  • 无服务器容器最多可存储 50 GB 的数据和索引。Serverless containers can store a maximum of 50 GB of data and indexes.

监视消耗量Monitoring your consumption

如果以前在预配吞吐量模式下使用了 Azure Cosmos DB,则会发现当流量证明预配容量不合理时,无服务器更加经济高效。If you have used Azure Cosmos DB in provisioned throughput mode before, you will find that serverless is more cost-effective when your traffic doesn't justify provisioned capacity. 权衡之处在于成本会不太容易预测,因为是基于数据库处理的请求数进行计费。The trade-off is that your costs will become less predictable because you are billed based on the number of requests your database has processed. 因此,请务必注意当前消耗量。Because of that, it's important to keep an eye on your current consumption.

当浏览帐户的“指标”窗格时,会在“概述”选项卡下找到名为“已消耗的请求单位”的图表 。此图表显示帐户已使用的请求单位数:When browsing the Metrics pane of your account, you will find a chart named Request Units consumed under the Overview tab. This chart shows how many Request Units your account has consumed:


使用 Azure Monitor 时,可以找到相同的图表,如此处所述。You can find the same chart when using Azure Monitor, as described here. 请注意,Azure Monitor 允许设置警报,可用于在请求单位消耗量超过特定阈值时通知你。Note that Azure Monitor lets you setup alerts, which can be used to notify you when your Request Unit consumption has passed a certain threshold.


无服务器资源会产生与预配吞吐量资源提供的性能特征不同的特定性能特征:Serverless resources yield specific performance characteristics that are different from what provisioned throughput resources deliver:

  • 可用性:在无服务器产品/服务公开发布之后,如果未使用可用性区域(区域冗余),则无服务器容器可用性的服务级别协议 (SLA) 为 99.9%。Availability: After the serverless offer becomes generally available, the availability of serverless containers will be covered by a Service Level Agreement (SLA) of 99.9% when Availability Zones (zone redundancy) aren't used. 使用可用性区域时,SLA 为 99.99%。The SLA is 99.99% when Availability Zones are used.
  • 延迟:在无服务器产品/服务公开发布之后,无服务器容器延迟的服务级别目标 (SLO) 对于点读取为 10 毫秒或更少,对于写入为 30 毫秒或更少。Latency: After the serverless offer becomes generally available, the latency of serverless containers will be covered by a Service Level Objective (SLO) of 10 milliseconds or less for point-reads and 30 milliseconds or less for writes. 点读取操作包含按其 ID 和分区键值提取单个项。A point-read operation consists in fetching a single item by its ID and partition key value.
  • 突发性:在无服务器产品/服务公开发布之后,无服务器容器突发性的服务级别目标 (SLO) 为 95%。Burstability: After the serverless offer becomes generally available, the burstability of serverless containers will be covered by a Service Level Objective (SLO) of 95%. 这意味着至少在 95% 的时间内可以获得最大突发性。This means the maximum burstability can be attained at least 95% of the time.


与任何 Azure 预览版一样,Azure Cosmos DB 无服务器不包括在服务级别协议 (SLA) 中。As any Azure preview, Azure Cosmos DB serverless is excluded from Service Level Agreements (SLA). 上面提到的性能特征作为此产品/服务在公开发布时提供的功能的预览版进行提供。The performance characteristics mentioned above are provided as a preview of what this offer will deliver when generally available.

后续步骤Next steps

可通过以下文章开始使用无服务器:Get started with serverless with the following articles: