在powershell中使用Azure CLI创建CosmosDB
我正试图创建一个新的cosmosdb,但在执行下面的代码时出现以下错误在powershell中使用Azure CLI创建CosmosDB,powershell,azure,azure-cosmosdb,azure-cli,Powershell,Azure,Azure Cosmosdb,Azure Cli,我正试图创建一个新的cosmosdb,但在执行下面的代码时出现以下错误 az cosmosdb create --name TIC_Test --resource-group "TIC" --default-consistency-level Session --locations "Central US"=0 "Central US"=0
az cosmosdb create --name TIC_Test
--resource-group "TIC"
--default-consistency-level Session
--locations "Central US"=0 "Central US"=0
--max-interval 5 --max-staleness-prefix 100
--enable-automatic-failover false
--enable-virtual-network false
--kind GlobalDocumentDB
错误:
az : usage: az cosmosdb create [-h] [--verbose] [--debug]
At line:2 char:1
+ az cosmosdb create --name TIC_Test --resource-group "TIC" --default- ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (usage: az cosmo...bose] [--debug]:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
[--output {json,jsonc,table,tsv}] [--query JMESPATH]
--resource-group RESOURCE_GROUP_NAME --name
ACCOUNT_NAME [--locations LOCATIONS [LOCATIONS ...]]
[--tags [TAGS [TAGS ...]]]
[--kind {GlobalDocumentDB,MongoDB,Parse}]
[--default-consistency-level {Eventual,Session,BoundedStaleness,Strong,ConsistentPrefix}]
[--max-staleness-prefix MAX_STALENESS_PREFIX]
[--max-interval MAX_INTERVAL]
[--ip-range-filter IP_RANGE_FILTER [IP_RANGE_FILTER ...]]
[--enable-automatic-failover [{true,false}]]
[--capabilities CAPABILITIES [CAPABILITIES ...]]
[--enable-virtual-network [{true,false}]]
[--virtual-network-rules VIRTUAL_NETWORK_RULES [VIRTUAL_NETWORK_RULES ...]]
[--subscription _SUBSCRIPTION]
az cosmosdb create: error: list index out of range
你知道错误的原因吗
我怀疑这一行,但我不确定如何指定:
--locations "Central US"=0 "Central US"=0
--locations选项允许您指定故障转移优先级
下面是一个创建新CosmosDB/SQL帐户的示例,其中美国东部是主帐户(读写),美国西部是次帐户(只读)
az cosmosdb create --name "cosmosdb5555" --kind GlobalDocumentDB --resource-group "cosmosdbrg" --locations "eastus=0", "westus=1"
您观察到一个错误,因为由于重复的区域和语法,您指定的--locations无效
如果在--位置中指定重复区域,将引发以下错误:
Operation failed with status: 'BadRequest'. Details: Failover priorities must be unique and 0 <= priority < (number of failover policies)
ActivityId: 689752f6-8081-11e8-8a4b-9cb6d00f36f2, Microsoft.Azure.Documents.Common/2.0.0.0
操作失败,状态为:“BadRequest”。详细信息:故障转移优先级必须是唯一的,0是,--位置似乎是问题所在。根据报告:
“regionName=failoverPriority”格式的空格分隔位置。例如
东美国=0西美国=1。写入区域的故障转移优先级值为0
读取区域大于0。故障转移优先级值必须为
唯一且少于区域总数。默认值:单个
指定资源组位置中的区域帐户
例如,将CentralUS配置为读/写区域,将EastUS配置为读区域:
--locations "CentralUS=0" "EastUS=1"
非常感谢,问题是我使用的格式,非常感谢!