You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -24,7 +24,7 @@ This quickstart demonstrates how to create an Azure Cosmos DB [SQL API](sql-api-
24
24
25
25
Azure Cosmos DB is Microsoft’s globally distributed multi-model database service. You can quickly create and query documents, key/value, wide column and graph databases. All of these operations benefit from the distribution and scale of Azure Cosmos DB.
26
26
27
-
This quickstart uses version 3.0 of the [Python SDK](https://pypi.org/project/azure-cosmos).
27
+
This quickstart uses version 4 of the [Python SDK](https://pypi.org/project/azure-cosmos/#history).
@@ -81,92 +81,50 @@ Now let's clone a SQL API app from GitHub, set the connection string, and run it
81
81
82
82
Now go back to the Azure portal to get your connection string information and copy it into the app.
83
83
84
-
1. In the [Azure portal](https://portal.azure.com/), in your Azure Cosmos account, in the left navigation select**Keys**. You'll use the copy buttons on the right side of the screen to copy the **URI** and **Primary Key** into the `CosmosGetStarted.py` file in the next step.
84
+
1. In the [Azure portal](https://portal.azure.com/), in your Azure Cosmos account, in the left navigation select**Keys**. You'll use the copy buttons on the right side of the screen to copy the **URI** and **Primary Key** into the `cosmos_get_started.py` file in the next step.
85
85
86
86

87
87
88
-
2. Open the `CosmosGetStarted.py` file in \git-samples\azure-cosmos-db-python-getting-started in Visual Studio Code.
88
+
2. Open the `cosmos_get_started.py` file in \git-samples\azure-cosmos-db-python-getting-started in Visual Studio Code.
89
89
90
-
3. Copy your **URI** value from the portal (using the copy button) and make it the value of the **endpoint** key in ``CosmosGetStarted.py``.
90
+
3. Copy your **URI** value from the portal (using the copy button) and make it the value of the **endpoint** variable in ``cosmos_get_started.py``.
4. Then copy your **PRIMARY KEY** value from the portal and make it the value of the **config.PRIMARYKEY** in ``CosmosGetStarted.py``. You've now updated your app with all the info it needs to communicate with Azure Cosmos DB.
94
+
4. Then copy your **PRIMARY KEY** value from the portal and make it the value of the **key** in ``cosmos_get_started.py``. You've now updated your app with all the info it needs to communicate with Azure Cosmos DB.
95
95
96
-
`'PRIMARYKEY': 'FILLME',`
96
+
`key = 'FILLME'`
97
97
98
-
5. Save the ``CosmosGetStarted.py`` file.
98
+
5. Save the ``cosmos_get_started.py`` file.
99
99
100
100
## Review the code
101
101
102
102
This step is optional. Learn about the database resources created in code, or skip ahead to [Update your connection string](#update-your-connection-string).
103
103
104
-
Note, if you are familiar with the previous version of the Python SDK, you may be used to seeing the terms "collection" and "document." Because Azure Cosmos DB supports multiple API models, version 3.0+ of the Python SDK uses the generic terms "container,", which may be a collection, graph, or table and "item" to describe the content of the container.
104
+
The following snippets are all taken from the `cosmos_get_started.py` file.
105
105
106
-
The following snippets are all taken from the `CosmosGetStarted.py` file.
106
+
*The CosmosClient is initialized. Make sure to update the "endpoint" and "key" values as described in the [Update your connection string](#update-your-connection-string) section.
107
107
108
-
* The CosmosClient is initialized. Make sure to update the "Endpoint" and "master key" values as described in the [Update your connection string](#update-your-connection-string) section.
* A new container is created, with 400 RU/s of [provisioned throughput](request-units.md). We choose `lastName` as the [partition key](partitioning-overview.md#choose-partitionkey), which allows us to do efficient queries that filter on this property.
* Some items are added to the container. Containers are a collection of items (JSON documents) that can have varied schema. The helper methods ```get_[name]_family_item```return representations of a family that are stored in Azure Cosmos DB as JSON documents.
* A query is performed using SQL query syntax. Because we're using partition key values of ```lastName``` in the WHERE clause, Azure Cosmos DB will efficiently route this query to the relevant partitions, improving performance.
@@ -187,20 +145,48 @@ The following snippets are all taken from the `CosmosGetStarted.py` file.
187
145
5. Run the following command to install the azure-cosmos package.
188
146
189
147
```python
190
-
pip3 install azure-cosmos
148
+
pip3 install azure-cosmos==4.0.0b5
191
149
```
192
150
193
151
If you get an error about access being denied when attempting to install azure-cosmos, you'll need to [run VS Code as an administrator](https://stackoverflow.com/questions/37700536/visual-studio-code-terminal-how-to-run-a-command-with-administrator-rights).
194
152
195
-
6. Run the following command to run the sample and create and store new documents in Azure Cosmos dB.
153
+
6. Run the following command to run the sample and create and store new documents in Azure Cosmos DB.
196
154
197
155
```python
198
-
python CosmosGetStarted.py
156
+
python cosmos_get_started.py
199
157
```
200
158
201
-
7. To confirm the new items were created and saved, in the Azure portal, select **Data Explorer**, expand **coll**, expand **Documents**, and then select the **server1** document. The server1 document contents match the content returned in the integrated terminal window.
202
-
203
-

159
+
7. To confirm the new items were created and saved, in the Azure portal, select**Data Explorer**>**AzureSampleFamilyDatabase**>**Items**. View the items that were created. For example, here is a sample JSON document for the Wakefield family:
0 commit comments