Skip to content

Commit b2d73eb

Browse files
Additional changes.
1 parent be6aff9 commit b2d73eb

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

articles/cosmos-db/table-storage-how-to-use-c-plus.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ ms.service: cosmos-db
55
ms.subservice: cosmosdb-table
66
ms.devlang: cpp
77
ms.topic: sample
8-
ms.date: 04/05/2018
8+
ms.date: 10/07/2019
99
author: wmengmsft
1010
ms.author: wmeng
1111
---
@@ -16,7 +16,7 @@ ms.author: wmeng
1616

1717
## Overview
1818

19-
This guide will show you common scenarios by using the Azure Table storage service or Azure Cosmos DB Table API. The samples are written in C++ and use the [Azure Storage Client Library for C++](https://github.com/Azure/azure-storage-cpp/blob/master/README.md). This article covers the following scenarios:
19+
This guide shows you common scenarios by using the Azure Table storage service or Azure Cosmos DB Table API. The samples are written in C++ and use the [Azure Storage Client Library for C++](https://github.com/Azure/azure-storage-cpp/blob/master/README.md). This article covers the following scenarios:
2020

2121
* Creating and deleting a table
2222
* Working with table entities
@@ -41,11 +41,11 @@ This guide will show you common scenarios by using the Azure Table storage servi
4141

4242
## Create a C++ application
4343

44-
In this guide, you use storage features from C++ application. To do so, install the Azure Storage Client Library for C++.
44+
In this guide, you use storage features from a C++ application. To do so, install the Azure Storage Client Library for C++.
4545

4646
To install the Azure Storage Client Library for C++, you can use the following methods:
4747

48-
* Linux. Follow the instructions given in [Azure Storage Client Library for C++](https://github.com/Azure/azure-storage-cpp/blob/master/README.md) page.
48+
* Linux. Follow the instructions given in [Azure Storage Client Library for C++](https://github.com/Azure/azure-storage-cpp/blob/master/README.md).
4949
* Windows. In Visual Studio, select **Tools > NuGet Package Manager > Package Manager Console**. Run the following command in the **Package Management Console**:
5050

5151
```powershell
@@ -56,7 +56,7 @@ For more information about **Package Management Console**, see [Install and mana
5656

5757
### Configure access to the Table client library
5858

59-
Add the following include statements to the top of the C++ file where you want to use the Azure storage APIs to access tables:
59+
Add the following `include` statements to the top of the C++ file where you want to use the Azure storage APIs to access tables:
6060

6161
```cpp
6262
#include <was/storage_account.h>
@@ -87,14 +87,14 @@ const utility::string_t storage_connection_string(U("DefaultEndpointsProtocol=ht
8787

8888
Use the name of your Azure Cosmos DB account, your primary key, and endpoint listed in the [Azure portal](https://portal.azure.com).
8989

90-
To test your application in your local Windows-based computer, you can use the Azure [storage emulator](../storage/common/storage-use-emulator.md) that is installed with the [Azure SDK](https://azure.microsoft.com/downloads/). The storage emulator is a utility that simulates the Azure Blob, Queue, and Table services available on your local development machine. The following example shows how you can declare a static field to hold the connection string to your local storage emulator:
90+
To test your application in your local Windows-based computer, you can use the Azure storage emulator that is installed with the [Azure SDK](https://azure.microsoft.com/downloads/). The storage emulator is a utility that simulates the Azure Blob, Queue, and Table services available on your local development machine. The following example shows how you can declare a static field to hold the connection string to your local storage emulator:
9191

9292
```cpp
9393
// Define the connection string with Azure storage emulator.
9494
const utility::string_t storage_connection_string(U("UseDevelopmentStorage=true;"));
9595
```
9696
97-
To start the Azure storage emulator, select the **Start** button or press the Windows key. Enter and run *Azure Storage Emulator*.
97+
To start the Azure storage emulator, select the **Start** button or the Windows key. Enter and run *Azure Storage Emulator*. For more information, see [Use the Azure storage emulator for development and testing](../storage/common/storage-use-emulator.md).
9898
9999
### Retrieve your connection string
100100
@@ -136,7 +136,7 @@ table.create_if_not_exists();
136136

137137
To add an entity to a table, create a new `table_entity` object and pass it to `table_operation::insert_entity`. The following code uses the customer's first name as the row key and last name as the partition key. Together, an entity's partition and row key uniquely identify the entity in the table. Entities with the same partition key can be queried faster than entities with different partition keys. Using diverse partition keys allows for greater parallel operation scalability. For more information, see [Microsoft Azure storage performance and scalability checklist](../storage/common/storage-performance-checklist.md).
138138

139-
The following code creates a new instance of `table_entity` with some customer data to store. The code next calls `table_operation::insert_entity` to create a `table_operation` object to insert an entity into a table, and associates the new table entity with it. Finally, the code calls the execute method on the `cloud_table` object. And the new `table_operation` sends a request to the Table service to insert the new customer entity into the "people" table.
139+
The following code creates a new instance of `table_entity` with some customer data to store. The code next calls `table_operation::insert_entity` to create a `table_operation` object to insert an entity into a table, and associates the new table entity with it. Finally, the code calls the execute method on the `cloud_table` object. And the new `table_operation` sends a request to the Table service to insert the new customer entity into the `people` table.
140140

141141
```cpp
142142
// Retrieve the storage account from the connection string.
@@ -226,7 +226,7 @@ Some things to note on batch operations:
226226

227227
### Retrieve all entities in a partition
228228

229-
To query a table for all entities in a partition, use a `table_query` object. The following code example specifies a filter for entities where 'Smith' is the partition key. This example prints the fields of each entity in the query results to the console.
229+
To query a table for all entities in a partition, use a `table_query` object. The following code example specifies a filter for entities where `Smith` is the partition key. This example prints the fields of each entity in the query results to the console.
230230

231231
> [!NOTE]
232232
> These methods are not currently supported for C++ in Azure Cosmos DB.
@@ -265,7 +265,7 @@ The query in this example brings all the entities that match the filter criteria
265265

266266
### Retrieve a range of entities in a partition
267267

268-
If you don't want to query all the entities in a partition, you can specify a range. Combine the partition key filter with a row key filter. The following code example uses two filters to get all entities in partition 'Smith' where the row key (first name) starts with a letter earlier than 'E' in the alphabet and then prints the query results.
268+
If you don't want to query all the entities in a partition, you can specify a range. Combine the partition key filter with a row key filter. The following code example uses two filters to get all entities in partition `Smith` where the row key (first name) starts with a letter earlier than `E` in the alphabet and then prints the query results.
269269

270270
> [!NOTE]
271271
> These methods are not currently supported for C++ in Azure Cosmos DB.
@@ -306,7 +306,7 @@ for (; it != end_of_results; ++it)
306306
307307
### Retrieve a single entity
308308
309-
You can write a query to retrieve a single, specific entity. The following code uses `table_operation::retrieve_entity` to specify the customer 'Jeff Smith'. This method returns just one entity, rather than a collection, and the returned value is in `table_result`. Specifying both partition and row keys in a query is the fastest way to retrieve a single entity from the Table service.
309+
You can write a query to retrieve a single, specific entity. The following code uses `table_operation::retrieve_entity` to specify the customer `Jeff Smith`. This method returns just one entity, rather than a collection, and the returned value is in `table_result`. Specifying both partition and row keys in a query is the fastest way to retrieve a single entity from the Table service.
310310
311311
```cpp
312312
azure::storage::cloud_storage_account storage_account = azure::storage::cloud_storage_account::parse(storage_connection_string);
@@ -332,7 +332,7 @@ std::wcout << U("PartitionKey: ") << entity.partition_key() << U(", RowKey: ") <
332332

333333
### Replace an entity
334334

335-
To replace an entity, retrieve it from the Table service, modify the entity object, and then save the changes back to the Table service. The following code changes an existing customer's phone number and email address. Instead of calling `table_operation::insert_entity`, this code uses `table_operation::replace_entity`. This approach causes the entity to be fully replaced on the server, unless the entity on the server has changed since it was retrieved. If it has been changed, the operation fails. This failure prevents your application from overwriting a change made between the retrieval and update by another component. The proper handling of this failure is to retrieve the entity again, make your changes, if still valid, and then do another `table_operation::replace_entity` operation. The next section will show you how to override this behavior.
335+
To replace an entity, retrieve it from the Table service, modify the entity object, and then save the changes back to the Table service. The following code changes an existing customer's phone number and email address. Instead of calling `table_operation::insert_entity`, this code uses `table_operation::replace_entity`. This approach causes the entity to be fully replaced on the server, unless the entity on the server has changed since it was retrieved. If it has been changed, the operation fails. This failure prevents your application from overwriting a change made between the retrieval and update by another component. The proper handling of this failure is to retrieve the entity again, make your changes, if still valid, and then do another `table_operation::replace_entity` operation. The next section shows you how to override this behavior.
336336

337337
```cpp
338338
// Retrieve the storage account from the connection string.
@@ -441,7 +441,7 @@ for (; it != end_of_results; ++it)
441441
442442
### Delete an entity
443443

444-
You can delete an entity after you retrieve it. After you retrieve an entity, call `table_operation::delete_entity` with the entity to delete. Then call the `cloud_table.execute` method. The following code retrieves and deletes an entity with a partition key of "Smith" and a row key of "Jeff".
444+
You can delete an entity after you retrieve it. After you retrieve an entity, call `table_operation::delete_entity` with the entity to delete. Then call the `cloud_table.execute` method. The following code retrieves and deletes an entity with a partition key of `Smith` and a row key of `Jeff`.
445445

446446
```cpp
447447
// Retrieve the storage account from the connection string.
@@ -466,7 +466,7 @@ azure::storage::table_result delete_result = table.execute(delete_operation);
466466

467467
### Delete a table
468468

469-
Finally, the following code example deletes a table from a storage account. A table that has been deleted will be unavailable to be re-created for some time following the deletion.
469+
Finally, the following code example deletes a table from a storage account. A table that has been deleted is unavailable to be re-created for some time following the deletion.
470470

471471
```cpp
472472
// Retrieve the storage account from the connection string.

0 commit comments

Comments
 (0)