问题描述
我正在编写一个 PowerShell 脚本,我需要在其中使用 sql api 创建多个 Cosmos DB 容器。
我在创建 Cosmos DB 帐户时已启用分析存储:
New-AzCosmosDBAccount -ResourceGroupName $resourceGroupName `
-Location $locations -Name $cosmosAccountName `
-ApiKind $apiKind -EnableAutomaticFailover:$true `
-DefaultConsistencyLevel $consistencyLevel `
-MaxStalenessIntervalInSeconds $maxStalenessInterval `
-MaxStalenessPrefix $maxStalenessPrefix `
-EnableAnalyticalStorage $true
然后我创建了一个 Cosmos DB sql 数据库,然后创建了容器。 我想像这样使用 -AnalyticalStorageTtl -1 启用分析存储:
New-AzCosmosDBsqlContainer `
-ResourceGroupName $resourceGroupName `
-AccountName $cosmosAccountName `
-DatabaseName $databaseName `
-Name $cosmosDbContainerName1 `
-PartitionKeyKind Hash `
-PartitionKeyPath $partitionKeyPath `
-AnalyticalStorageTtl -1
但我收到一条错误消息,提示“-AnalyticalStorageTtl -1 未被识别为 cmdlet[...]”。 此参数在 PowerShell cmdlet 上不可用。但是它可以使用 this Azure CLI command.
我是不是遗漏了什么,或者这个参数在 PS cmdlet 中不可用? PowerShell 是否有任何解决方法?
解决方法
感谢您报告此事。我查了一下,这确实在 Cosmos DB PowerShell cmdlet 中遗漏了。已提交 Pull Request 以更正此问题,它应该会出现在 1 月 19 日的下一个 customer release 中。--谢谢。