Share via


你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

ContainerProperties 类

定义

表示 Azure Cosmos DB 服务中的文档容器。 容器是文档的命名逻辑容器。

public class ContainerProperties
type ContainerProperties = class
Public Class ContainerProperties
继承
ContainerProperties

示例

以下示例创建一个新的分区容器,其每单位请求吞吐量为 50000。 分区键是此容器内所有文档的第一级“country”属性。

Container container = await client.GetDatabase("dbName").Containers.CreateAsync("MyCollection", "/country", 50000);
ContainerProperties containerProperties = container.Resource;

以下示例使用自定义索引策略创建新的容器。

ContainerProperties containerProperties = new ContainerProperties("MyCollection", "/country");
containerProperties.IndexingPolicy.Automatic = true;
containerProperties.IndexingPolicy.IndexingMode = IndexingMode.Consistent;

CosmosContainerResponse containerCreateResponse = await client.GetDatabase("dbName").CreateContainerAsync(containerProperties, 50000);
ContainerProperties createdContainerProperties = containerCreateResponse.Container;

以下示例删除此容器。

Container container = client.GetDatabase("dbName").Containers["MyCollection"];
await container.DeleteAsync();

注解

数据库可能包含零个或多个命名容器,每个容器由零个或多个 JSON 文档组成。 由于没有架构,容器中的文档不需要共享相同的结构或字段。 由于容器是应用程序资源,因此可以使用主密钥或资源密钥进行授权。

构造函数

ContainerProperties()

为 Azure Cosmos DB 服务初始化 类的新实例 ContainerProperties

ContainerProperties(String, IReadOnlyList<String>)

为 Azure Cosmos DB 服务初始化 类的新实例 ContainerProperties

ContainerProperties(String, String)

为 Azure Cosmos DB 服务初始化 类的新实例 ContainerProperties

属性

AnalyticalStoreTimeToLiveInSeconds

获取或设置 Azure Cosmos 服务的容器范围内分析存储的生存时间(以秒为单位)。

启用分析存储时会捕获容器中的所有项更改。 AnalysisStoreTimeToLiveInSeconds 定义分析存储中更改的生存时间。

ClientEncryptionPolicy

获取或设置用于从 Azure Cosmos 服务将项存储在容器中的客户端加密策略信息。

ConflictResolutionPolicy

获取或设置 ConflictResolutionPolicy

DefaultTimeToLive

获取或设置 Azure Cosmos 服务容器中项的默认生存时间(以秒为单位)。

ETag

从 Azure Cosmos DB 服务中获取与资源关联的实体标记。

GeospatialConfig

GeospatialConfig从 Azure Cosmos DB 服务获取与集合关联的 。

Id

获取或设置 Azure Cosmos DB 服务中资源的 ID。

IndexingPolicy

IndexingPolicy从 Azure Cosmos DB 服务获取与容器关联的 。

LastModified

从 Azure Cosmos DB 服务中获取与 ContainerProperties 关联的上次修改时间戳。

PartitionKeyDefinitionVersion

获取或设置 PartitionKeyDefinitionVersion

分区键定义版本 1 使用哈希函数,该函数基于分区键的前 100 个字节计算哈希。 这可能会导致分区键大于 100 字节的文档发生冲突。

分区键定义版本 2 使用哈希函数,该函数基于分区键的前 2 KB 计算哈希。

PartitionKeyPath

用于容器分区的 JSON 路径

PartitionKeyPaths

用于具有分层分区键的容器的 JSON 路径列表

SelfLink

从 Azure Cosmos DB 服务获取与资源关联的自链接。

TimeToLivePropertyPath
已过时.

获取或设置生存时间基时间戳属性路径。

UniqueKeyPolicy

获取或设置 , UniqueKeyPolicy 用于保证 Azure Cosmos DB 服务中容器中的文档的唯一性。

适用于

另请参阅