Skip to content

Commit f6189ff

Browse files
authored
Merge pull request #89721 from SnehaGunda/LandingPage2
Updating content to access documents without partition key
2 parents cd8dd57 + 1dc4b0d commit f6189ff

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed

articles/cosmos-db/migrate-containers-partitioned-to-nonpartitioned.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: Learn how to migrate all the existing non-partitioned containers in
44
author: markjbrown
55
ms.service: cosmos-db
66
ms.topic: conceptual
7-
ms.date: 05/23/2019
7+
ms.date: 09/25/2019
88
ms.author: mjbrown
99
---
1010

@@ -14,12 +14,12 @@ Azure Cosmos DB supports creating containers without a partition key. Currently
1414

1515
The non-partitioned containers are legacy and you should migrate your existing non-partitioned containers to partitioned containers to scale storage and throughput. Azure Cosmos DB provides a system defined mechanism to migrate your non-partitioned containers to partitioned containers. This document explains how all the existing non-partitioned containers are auto-migrated into partitioned containers. You can take advantage of the auto-migration feature only if you are using the V3 version of SDKs in all the languages.
1616

17-
> [!NOTE]
18-
> Currently, you cannot migrate Azure Cosmos DB MongoDB and Gremlin API accounts by using the steps described in this document.
17+
> [!NOTE]
18+
> Currently, you cannot migrate Azure Cosmos DB MongoDB and Gremlin API accounts by using the steps described in this document.
1919
2020
## Migrate container using the system defined partition key
2121

22-
To support the migration, Azure Cosmos DB defines a system defined partition key named `/_partitionkey` on all the containers that don’t have a partition key. You cannot change the partition key definition after the containers are migrated. For example, the definition of a container that is migrated to a partitioned container will be as follows:
22+
To support the migration, Azure Cosmos DB provides a system defined partition key named `/_partitionkey` on all the containers that don’t have a partition key. You cannot change the partition key definition after the containers are migrated. For example, the definition of a container that is migrated to a partitioned container will be as follows:
2323

2424
```json
2525
{
@@ -32,10 +32,10 @@ To support the migration, Azure Cosmos DB defines a system defined partition key
3232
},
3333
}
3434
```
35-
36-
After the container is migrated, you can create documents by populating the `_partitionKey` property along with the other properties of the document. The `_partitionKey` property represents the partition key of your documents.
3735

38-
Choosing the right partition key is important to utilize the provisioned throughput optimally. For more information, see [how to choose a partition key](partitioning-overview.md) article.
36+
After the container is migrated, you can create documents by populating the `_partitionKey` property along with the other properties of the document. The `_partitionKey` property represents the partition key of your documents.
37+
38+
Choosing the right partition key is important to utilize the provisioned throughput optimally. For more information, see [how to choose a partition key](partitioning-overview.md) article.
3939

4040
> [!NOTE]
4141
> You can take advantage of system defined partition key only if you are using the latest/V3 version of SDKs in all the languages.
@@ -60,37 +60,37 @@ public class DeviceInformationItem
6060
[JsonProperty(PropertyName = "deviceId")]
6161
public string DeviceId { get; set; }
6262

63-
[JsonProperty(PropertyName = "_partitionKey")]
63+
[JsonProperty(PropertyName = "_partitionKey", NullValueHandling = NullValueHandling.Ignore)]
6464
public string PartitionKey {get {return this.DeviceId; set; }
6565
}
6666

6767
CosmosContainer migratedContainer = database.Containers["testContainer"];
6868

6969
DeviceInformationItem deviceItem = new DeviceInformationItem() {
70-
Id = "1234",
70+
Id = "1234",
7171
DeviceId = "3cf4c52d-cc67-4bb8-b02f-f6185007a808"
72-
}
72+
}
7373

74-
CosmosItemResponse<DeviceInformationItem > response =
75-
await migratedContainer.Items.CreateItemAsync(
74+
ItemResponse<DeviceInformationItem > response =
75+
await migratedContainer.CreateItemAsync<DeviceInformationItem>(
7676
deviceItem.PartitionKey,
7777
deviceItem
7878
);
7979

8080
// Read back the document providing the same partition key
81-
CosmosItemResponse<DeviceInformationItem> readResponse =
82-
await migratedContainer.Items.ReadItemAsync<DeviceInformationItem>(
81+
ItemResponse<DeviceInformationItem> readResponse =
82+
await migratedContainer.ReadItemAsync<DeviceInformationItem>(
8383
partitionKey:deviceItem.PartitionKey,
8484
id: device.Id
85-
);
85+
);
8686

8787
```
8888

89-
For the complete sample, see the [.Net samples](https://github.com/Azure/azure-cosmos-dotnet-v3/tree/master/Microsoft.Azure.Cosmos.Samples/CodeSamples) GitHub repository.
89+
For the complete sample, see the [.Net samples](https://github.com/Azure/azure-cosmos-dotnet-v3/tree/master/Microsoft.Azure.Cosmos.Samples/CodeSamples) GitHub repository.
9090
9191
## Migrate the documents
9292

93-
While the container definition is enhanced with a partition key property, the documents within the container arent auto migrated. Which means the system partition key property `/_partitionKey` path is not automatically added to the existing documents. You need to repartition the existing documents by reading the documents that were created without a partition key and rewrite them back with `_partitionKey` property in the documents.
93+
While the container definition is enhanced with a partition key property, the documents within the container arent auto migrated. Which means the system partition key property `/_partitionKey` path is not automatically added to the existing documents. You need to repartition the existing documents by reading the documents that were created without a partition key and rewrite them back with `_partitionKey` property in the documents.
9494

9595
## Access documents that don't have a partition key
9696

@@ -99,7 +99,7 @@ Applications can access the existing documents that don’t have a partition key
9999
```csharp
100100
CosmosItemResponse<DeviceInformationItem> readResponse =
101101
await migratedContainer.Items.ReadItemAsync<DeviceInformationItem>(
102-
partitionKey: CosmosContainerSettings.NonePartitionKeyValue,
102+
partitionKey: PartitionKey.None,
103103
id: device.Id
104104
);
105105

articles/cosmos-db/working-with-dates.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ ms.service: cosmos-db
55
author: SnehaGunda
66
ms.author: sngun
77
ms.topic: conceptual
8-
ms.date: 07/23/2019
8+
ms.date: 09/25/2019
99
---
1010
# Working with Dates in Azure Cosmos DB
1111
Azure Cosmos DB delivers schema flexibility and rich indexing via a native [JSON](https://www.json.org) data model. All Azure Cosmos DB resources including databases, containers, documents, and stored procedures are modeled and stored as JSON documents. As a requirement for being portable, JSON (and Azure Cosmos DB) supports only a small set of basic types: String, Number, Boolean, Array, Object, and Null. However, JSON is flexible and allow developers and frameworks to represent more complex types using these primitives and composing them as objects or arrays.

0 commit comments

Comments
 (0)