重要
此功能目前以预览版提供,不提供服务级别协议。 目前,不建议在生产环境中使用预览功能。 此预览版的某些功能不受支持或可能具有功能约束。 有关详细信息,请参阅 Azure 预览版的补充使用条款。
本文提供创建和管理机队、舰队空间和机群空间帐户的分步说明。 按照此处的指导逐个设置和配置 Azure Cosmos DB 机队资源。 在本指南结束时,您将拥有一个完全配置的资源组,其中包括单个资源空间、吞吐量汇聚,以及注册的 Azure Cosmos DB 帐户作为资源空间帐户。
有关机队的详细信息,请参阅 机队概述。
先决条件
Azure 订阅服务
- 如果没有 Azure 订阅,可在开始前创建一个试用帐户。
为订阅注册 Azure Cosmos DB 舰队预览功能。
- 如果未注册, 请注册预览版。
- Azure 命令行接口 (CLI)
- 二头肌
创建机群
通过创建最终包含你的舰队空间的舰队和舰队空间帐户资源来设置舰队。 机群是一个高级实体,可在机群空间内跨不同的订阅和/或资源组组织和管理多个数据库帐户。 一个舰队对应于一个多租户应用程序。 指定车队的区域和唯一名称。
注释
为机队资源选择的区域不会影响或确定车队中任何数据库帐户的位置/区域。
登录到 Azure 门户 (https://portal.azure.cn)。
在全局搜索栏中输入 Cosmos DB 机群 。
在 “服务”中,选择 “Azure Cosmos DB 舰队”。
在 “Azure Cosmos DB 集群”页上,选择“+ 创建”。
在“基本信息”窗格中,配置以下选项,然后选择“查看 + 创建” :
价值 订阅 选择 Azure 订阅 资源组 创建新的资源组或选择现有资源组 舰队名称 提供多区域唯一名称 区域 为订阅选择受支持的 Azure 区域 在 “审阅 + 创建 ”窗格中,等待队列的验证成功完成,然后选择“ 创建”。
使用
az resource create
和空的({}
)JSON 属性对象创建车队:az resource create \ --resource-group "<resource-group-name>" \ --name "<fleet-name>" \ --resource-type "Microsoft.DocumentDB/fleets" \ --location "<azure-region>" \ --latest-include-preview \ --properties "{}"
(可选)执行常见的车队管理作,包括:
检索特定舰队。
az resource show \ --resource-group "<resource-group-name>" \ --name "<fleet-name>" \ --resource-type "Microsoft.DocumentDB/fleets" \ --latest-include-preview
列出资源组中的所有机群。
az resource list \ --resource-group "<resource-group-name>" \ --resource-type "Microsoft.DocumentDB/fleets"
删除特定机群。
az resource delete \ --resource-group "<resource-group-name>" \ --name "<fleet-name>" \ --resource-type "Microsoft.DocumentDB/fleets" \ --latest-include-preview
resource fleet 'Microsoft.DocumentDB/fleets@2025-05-01-preview' = {
name: '<fleet-name>'
location: '<azure-region>'
properties: {}
}
创建舰队空间
在将帐户添加到舰队之前,必须创建舰队空间。 机群空间是机群中数据库帐户的逻辑分组,其中 RU/s 可以选择在机群空间内的数据库帐户中的所有资源之间共享。 车队中的每个数据库帐户都必须属于一个特定的车队空间。
注释
在本指南中,为舰队空间配置了吞吐量池。 可以选择不使用吞吐量池。 吞吐量池是一种可选配置,允许帐户资源共享 RU/s。 此共享 RU/s 位于已可用于资源的专用 RU/s 之上。
池中的 RU/秒最小值和最大值可以随时进行调整。 创建舰队空间后,服务层级和数据区域无法更改。
若要为机群空间配置吞吐量池,请指定适用于机群空间内所有帐户的区域和服务层。 如果配置了吞吐量池,则机群空间中的所有帐户必须共享相同的区域和服务层配置。
有关详细信息,请参阅舰队池。
导航到 Azure 门户中的现有舰队资源。
在资源菜单的“舰队资源”部分中选择“机队空间”选项。
在对话框中,配置以下选项,然后选择“ 确定” :
价值 舰队空间名称 为您的车队指定一个唯一的名称 启用吞吐量池 选中复选框 为吞吐量池中的帐户选择区域 选择并为吞吐量池中的帐户添加区域列表 为吞吐量池中的帐户选择写入区域类型 选择 单写入区域 (常规用途)或 多写入区域 (业务关键) 吞吐量池最小 RU/s 整数,不小于 100,000,并且必须是 1,000 的倍数 吞吐量池最大 RU/s 整数,不小于 100,000,或小于 throughputPoolConfiguration.minThroughput
且必须是 1,000 的倍数
在您的车队中使用以下属性创建一个编队空间:
价值 fleetspaceAPIKind
NoSQL
throughputPoolConfiguration.minThroughput
整数,不小于 100,000,并且必须是 1,000 的倍数 throughputPoolConfiguration.maxThroughput
整数,不小于 100,000,或小于 throughputPoolConfiguration.minThroughput
且必须是 1,000 的倍数throughputPoolConfiguration.serviceTier
也 GeneralPurpose
或BusinessCritical
throughputPoolConfiguration.dataRegions
吞吐量池中帐户的区域列表 json=$(jq \ --arg "locationName" "<azure-region>" \ --arg "api" "NoSQL" \ --arg "minRUs" 100000 \ --arg "maxRUs" 100000 \ --arg "tier" "GeneralPurpose" \ --null-input \ --compact-output \ '{fleetspaceAPIKind:$api,throughputPoolConfiguration:{minThroughput:$minRUs,maxThroughput:$maxRUs,serviceTier:$tier,dataRegions:[$locationName]}}' \ ) az resource create \ --resource-group "<resource-group-name>" \ --name "<fleet-name>/fleetspaces/<fleetspace-name>" \ --resource-type "Microsoft.DocumentDB/fleets/fleetspaces/" \ --location "<azure-region>" \ --latest-include-preview \ --properties $json
小窍门
您可以根据您的需求配置
minThroughput
、maxThroughput
、writeRegionType
和dataRegions
属性。(可选)执行常见的舰队空间管理操作,包括:
检索舰队中的特定舰队空间。
az resource show \ --resource-group "<resource-group-name>" \ --name "<fleet-name>/fleetspaces/<fleetspace-name>" \ --resource-type "Microsoft.DocumentDB/fleets/fleetspaces/" \ --latest-include-preview
列出舰队中的所有舰队空间。
az resource list \ --resource-group "<resource-group-name>" \ --resource-type "Microsoft.DocumentDB/fleets/fleetspaces/"
删除舰队中的特定舰队空间。
az resource delete \ --resource-group "<resource-group-name>" \ --name "<fleet-name>/fleetspaces/<fleetspace-name>" \ --resource-type "Microsoft.DocumentDB/fleets/fleetspaces/" \ --latest-include-preview
价值 | |
---|---|
fleetspaceAPIKind |
NoSQL |
throughputPoolConfiguration.minThroughput |
整数,不小于 100,000,并且必须是 1,000 的倍数 |
throughputPoolConfiguration.maxThroughput |
整数,不小于 100,000,或小于throughputPoolConfiguration.minThroughput 且必须是 1,000 的倍数 |
throughputPoolConfiguration.serviceTier |
也GeneralPurpose 或BusinessCritical |
throughputPoolConfiguration.dataRegions |
吞吐量池中帐户的区域列表 |
resource fleetspace 'Microsoft.DocumentDB/fleets/fleetspaces@2025-05-01-preview' = {
name: '<fleetspace-name>'
parent: fleet
location: '<azure-region>'
properties: {
fleetspaceAPIKind: 'NoSQL'
throughputPoolConfiguration: {
minThroughput: 100000
maxThroughput: 100000
serviceTier: 'SingleRegionWrite'
dataRegions: [
'<azure-region>'
]
}
}
}
小窍门
您可以根据您的需求配置minThroughput
、maxThroughput
、writeRegionType
和dataRegions
属性。
将帐户添加到舰队空间
创建舰队空间后,请将帐户添加到舰队空间本身。 任何订阅/资源组中的帐户都可以添加到集群。 为舰队空间配置池时,这些资源会从池中使用 RU/s。
重要
无法将帐户添加到已与现有舰队空间关联的舰队空间。
在资源菜单的“舰队资源”部分中选择“数据库帐户”选项。
在 “Fleetspace ”部分中,选择现有的机群空间。
然后,启用“浏览要添加到此舰队空间的帐户”选项。
选择现有的 Azure Cosmos DB for NoSQL 帐户,然后选择“ + 添加到机群空间”。
使用以下属性在舰队空间中创建舰队空间帐户:
价值 accountLocation
Azure Cosmos DB 帐户的位置。 accountResourceIdentifier
目标 Azure Cosmos DB 帐户的完全限定的资源标识符。 databaseResourceId=$(az resource show \ --resource-group "<resource-group-name>" \ --name "<azure-cosmos-db-resource-name>" \ --resource-type "Microsoft.DocumentDB/databaseAccounts" \ --query "id" \ --output tsv \ ) json=$(jq \ --arg "locationName" "<azure-region>" \ --arg "accountResourceId" "$databaseResourceId" \ --null-input \ --compact-output \ '{accountLocation:$locationName,accountResourceIdentifier:$accountResourceId}' \ ) az resource create \ --resource-group "<resource-group-name>" \ --name "<fleet-name>/fleetspaces/<fleetspace-name>/fleetspaceAccounts/<fleetspace-account-name>" \ --resource-type "Microsoft.DocumentDB/fleets/fleetspaces/fleetspaceAccounts/" \ --location "<azure-region>" \ --latest-include-preview \ --properties $json
(可选)执行常见的舰队空间管理操作,包括:
检索舰队空间中的特定舰队空间帐户。
az resource show \ --resource-group "<resource-group-name>" \ --name "<fleet-name>/fleetspaces/<fleetspace-name>/fleetspaceAccounts/<fleetspace-account-name>" \ --resource-type "Microsoft.DocumentDB/fleets/fleetspaces/fleetspaceAccounts/" \ --latest-include-preview
列出舰队空间中的舰队空间帐户。
az resource list \ --resource-group "<resource-group-name>" \ --resource-type "Microsoft.DocumentDB/fleets/fleetspaces/fleetspaceAccounts/"
删除特定的舰队空间帐户。
az resource delete \ --resource-group "<resource-group-name>" \ --name "<fleet-name>/fleetspaces/<fleetspace-name>/fleetspaceAccounts/<fleetspace-account-name>" \ --resource-type "Microsoft.DocumentDB/fleets/fleetspaces/fleetspaceAccounts/" \ --latest-include-preview
价值 | |
---|---|
accountLocation |
Azure Cosmos DB 帐户的位置。 |
accountResourceIdentifier |
目标 Azure Cosmos DB 帐户的完全限定的资源标识符。 |
resource account 'Microsoft.DocumentDB/databaseAccounts@2024-12-01-preview' existing = {
name: '<azure-cosmos-db-resource-name>'
}
resource fleetspaceAccount 'Microsoft.DocumentDB/fleets/fleetspaces/fleetspaceAccounts@2025-05-01-preview' = {
name: '<fleetspace-account-name>'
parent: fleetspace
location: '<azure-region>'
properties: {
accountLocation: '<azure-region>'
accountResourceIdentifier: account.id
}
}