共用方式為


ContainerProperties Class

Definition

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

[System.Text.Json.Serialization.JsonConverter(typeof(Azure.Cosmos.TextJsonContainerPropertiesConverter))]
public class ContainerProperties
[<System.Text.Json.Serialization.JsonConverter(typeof(Azure.Cosmos.TextJsonContainerPropertiesConverter))>]
type ContainerProperties = class
Public Class ContainerProperties
Inheritance
ContainerProperties
Attributes

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. Refer to for more details on containers.

Constructors

ContainerProperties()

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

ConflictResolutionPolicy

Gets or sets the ConflictResolutionPolicy

DefaultTimeToLive

Gets 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.

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 the Partitioning scheme version used. PartitionKeyDefinitionVersion

PartitionKeyPath

JSON path used for containers partitioning

UniqueKeyPolicy

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

Applies to

See also