共用方式為


ContainerProperties Class

Definition

Represents a document container in the Azure Cosmos DB service. A container is a named logical container for documents.

public class ContainerProperties
type ContainerProperties = class
Public Class ContainerProperties
Inheritance
ContainerProperties

Examples

The example below creates a new partitioned container with 50000 Request-per-Unit throughput. The partition key is the first level 'country' property in all the documents within this container.

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

The example below creates a new container with a custom indexing policy.

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;

The example below deletes this container.

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

Remarks

A database may contain zero or more named containers and each container consists of zero or more JSON documents. Being schema-free, the documents in a container do not need to share the same structure or fields. Since containers are application resources, they can be authorized using either the master key or resource keys.

Constructors

ContainerProperties()

Initializes a new instance of the ContainerProperties class for the Azure Cosmos DB service.

ContainerProperties(String, IReadOnlyList<String>)

Initializes a new instance of the ContainerProperties class for the Azure Cosmos DB service.

ContainerProperties(String, String)

Initializes a new instance of the ContainerProperties class for the Azure Cosmos DB service.

Properties

AnalyticalStoreTimeToLiveInSeconds

Gets or sets the time to live for analytical store in seconds at container scope for the Azure Cosmos service.

Analytical store when enabled captures all the item changes in the container. AnalyticalStoreTimeToLiveInSeconds defines the time to live for the changes in analytical store.

ClientEncryptionPolicy

Gets or sets the client encryption policy information for storing items in a container from the Azure Cosmos service.

ConflictResolutionPolicy

Gets or sets the ConflictResolutionPolicy

DefaultTimeToLive

Gets or sets the default time to live in seconds for item in a container from the Azure Cosmos service.

ETag

Gets the entity tag associated with the resource from the Azure Cosmos DB service.

GeospatialConfig

Gets the GeospatialConfig associated with the collection from the Azure Cosmos DB service.

Id

Gets or sets the Id of the resource in the Azure Cosmos DB service.

IndexingPolicy

Gets the IndexingPolicy associated with the container from the Azure Cosmos DB service.

LastModified

Gets the last modified time stamp associated with ContainerProperties from the Azure Cosmos DB service.

PartitionKeyDefinitionVersion

Gets or sets the PartitionKeyDefinitionVersion

The partition key definition version 1 uses a hash function that computes hash based on the first 100 bytes of the partition key. This can cause conflicts for documents with partition keys greater than 100 bytes.

The partition key definition version 2 uses a hash function that computes hash based on the first 2 KB of the partition key.

PartitionKeyPath

JSON path used for containers partitioning

PartitionKeyPaths

List of JSON paths used for containers with hierarchical partition keys

SelfLink

Gets the self-link associated with the resource from the Azure Cosmos DB service.

TimeToLivePropertyPath
Obsolete.

Gets or sets the time to live base time stamp property path.

UniqueKeyPolicy

Gets or sets the UniqueKeyPolicy that guarantees uniqueness of documents in container in the Azure Cosmos DB service.

Applies to

See also