You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

是否存在可分配给Managed Identity的角色/操作以写入Cosmos DB容器索引策略?

能否给托管标识分配角色/操作以修改Cosmos DB容器的索引策略?

目前没有内置的Azure RBAC角色能直接让托管标识具备修改Cosmos DB容器索引策略的权限,你测试的DocumentDB Account Contributor、Cosmos DB Operator和Owner这几个角色确实都不支持该操作。

要实现这个需求,你需要创建自定义RBAC角色,并包含以下关键操作:

  • Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers/read
  • Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers/write

这两个操作分别对应读取容器配置和修改容器配置(包括索引策略)的权限。

对应的.NET CosmosClient修改索引策略的代码示例如下:

ContainerResponse containerResponse = await this.container.ReadContainerAsync();

containerResponse.Resource.IndexingPolicy = ...; // 设置或调整索引策略

await this.container.ReplaceContainerAsync(containerResponse.Resource);

内容的提问来源于stack exchange,提问作者Mo B.

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.07 22:08:24