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
Copy file name to clipboardExpand all lines: 07_Create_First_Cosmos_DB_Project/README.md
+17-52Lines changed: 17 additions & 52 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,16 +4,14 @@ This section will cover how to create your first Cosmos DB project. We'll use a
4
4
5
5
## Emulator support
6
6
7
-
Azure Cosmos DB has an emulator that can be used to develop code locally. The emulator supports the API for NoSQL and the API for NoSQL. The use of the emulator does not require an Azure subscription, nor does it incur any costs, so it is ideal for local development and testing. The Azure Cosmos DB emulator can also be utilized with unit tests in a [GitHub Actions CI workflow](https://learn.microsoft.com/azure/cosmos-db/how-to-develop-emulator?tabs=windows%2Cpython&pivots=api-mongodb#use-the-emulator-in-a-github-actions-ci-workflow).
7
+
Azure Cosmos DB has an emulator that can be used to develop code locally. The emulator supports the API for NoSQL and the API for MongoDB. The use of the emulator does not require an Azure subscription, nor does it incur any costs, so it is ideal for local development and testing. The Azure Cosmos DB emulator can also be utilized with unit tests in a [GitHub Actions CI workflow](https://learn.microsoft.com/azure/cosmos-db/how-to-develop-emulator?tabs=windows%2Cpython&pivots=api-mongodb#use-the-emulator-in-a-github-actions-ci-workflow).
8
8
9
9
There is not 100% feature parity between the emulator and the cloud service. Visit the [Azure Cosmos DB emulator](https://learn.microsoft.com/azure/cosmos-db/emulator) documentation for more details.
10
10
11
-
For Windows machines, the emulator can be installed via an installer. There is a Windows container using Docker available. However, it does not currently support the API for Mongo DB. A Docker image is also available for Linux that does support the API for Mongo DB.
11
+
For Windows machines, the emulator can be installed via an installer or by using a Docker container. A Docker image is also available for Linux-based machines.
12
12
13
13
Learn more about the pre-requisites and installation of the emulator [here](https://learn.microsoft.com/azure/cosmos-db/how-to-develop-emulator?tabs=windows%2Cpython&pivots=api-mongodb).
14
14
15
-
>**NOTE**: When using the Azure CosmosDB emulator using the API for MongoDB it must be started with the [MongoDB endpoint options enabled](https://learn.microsoft.com/azure/cosmos-db/how-to-develop-emulator?tabs=windows%2Cpython&pivots=api-mongodb#start-the-emulator) at the command-line.
16
-
17
15
**The Azure Cosmos DB emulator does not support vector search. To complete the vector search and AI-related labs, a Azure Cosmos DB for NoSQL account in Azure is required.**
18
16
19
17
## Authentication
@@ -24,93 +22,60 @@ Authentication to Azure Cosmos DB API for Mongo DB uses a connection string. The
24
22
25
23
The splash screen or **Quickstart** section of the Cosmos DB Emulator will display the connection string. Access this screen through the following URL: `https://localhost:8081/_explorer/index.html`.
26
24
27
-

25
+

28
26
29
27
### Retrieving the connection string from the Azure portal
30
28
31
-
Retrieve the connection string from the Azure portal by navigating to the Azure Cosmos DB account and selecting the **Connection String** menu item on the left-hand side of the screen. The connection string contains tokens for the username and password that must be replaced with the username and password used when provisioning the Azure Cosmos DB API for NoSQL service.
29
+
Retrieve the connection string from the Azure portal by navigating to the Azure Cosmos DB account and expanding the **Settings** menu item on the left-hand side of the screen. Locate the **Primary Connection String**, and select the icon to make it visible. Copy the connection string and paste it in notepad for future reference.
32
30
33
-

31
+

34
32
35
33
## Lab - Create your first Cosmos DB for the NoSQL application
36
34
37
-
Using a notebook, we'll create a Cosmos DB for the NoSQL application in this lab using the **pymongo** library and the Python language. Both the Azure Cosmos DB Emulator and Azure Cosmos DB account in Azure are supported for completion of this lab.
35
+
Using a notebook, we'll create a Cosmos DB for the NoSQL application in this lab using the **azure-cosmos** library and the Python language. Both the Azure Cosmos DB Emulator and Azure Cosmos DB account in Azure are supported for completion of this lab.
38
36
39
37
>**Note**: It is highly recommended to use a [virtual environment](https://python.land/virtual-environments/virtualenv) for all labs.
40
38
41
39
Please visit the lab repository to complete [this lab](../Labs/lab_1_first_application.ipynb).
42
40
43
41
The following concepts are covered in detail in this lab:
44
42
45
-
### Creating a MongoDB database client
43
+
### Creating a database client
46
44
47
-
The `pymongo` library is used to create a MongoDB database client. The client enables both DDL (data definition language) and DML (data manipulation language) operations.
45
+
The `azure-cosmos` library is used to create a Cosmos DB API for NoSQL database client. The client enables both DDL (data definition language) and DML (data manipulation language) operations.
When using the `pymongo` client, the creation of a database is automatic when referenced. No specific api calls to create a database are required, if a database already exists, a reference to the database is returned.
56
-
57
-
>**Note:**: That the creation of databases and containers are lazy, meaning they will not be created until a document is inserted into a container.
53
+
The `create_database` method is used to create a database. If the database already exists, an exception is thrown, therefore verify the database already exists before creating it.
58
54
59
55
```python
60
-
db =client.cosmic_works
56
+
client.create_database(id=id)
61
57
```
62
58
63
59
### Creating a container
64
60
65
-
Similar behavior to the creation of a database is experienced when creating a container. If the container does not exist, it will be created once a document is inserted into the container.
66
-
67
-
```python
68
-
collection = db.products
69
-
```
61
+
In progress
70
62
71
63
### Creating a document
72
64
73
-
The `insert_one` method is used to insert a document into a container. The document is a dictionary object.
74
-
75
-
```python
76
-
# Insert the JSON into the database, and retrieve the inserted/generated ID
Copy file name to clipboardExpand all lines: Labs/deploy/deploy.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,11 +19,7 @@ cd Labs
19
19
cd deploy
20
20
```
21
21
22
-
Open the `azuredeploy.parameters.json` file, then edit the `mongoDbPassword` to a password you wish to use for the MongoDB Admin User:
23
-
24
-

25
-
26
-
When the Azure Bicep template is deployed, this parameters file will be used to configure the Mongo DB Password and other parameters when provisioning the Azure resources.
22
+
Open the `azuredeploy.parameters.json` file, and inspect the values, modify as deemed appropriate.
To enroll in the DiskANN early preview, fill the following form [Azure Cosmos DB for NoSQL DiskANN Early Preview](https://forms.office.com/pages/responsepage.aspx?id=v4j5cvGGr0GRqy180BHbR7M9usLEDhFDufzz-8echE9UREtCOVhQWkZLVlhTRlNBM0lLUkdRTEwxUy4u&route=shorturl) and a member of the Cosmos DB team will reach out to you.
0 commit comments