Skip to content

Commit 1ce0f49

Browse files
committed
Updated deployment instructions, WIP on first app
1 parent 5dceff6 commit 1ce0f49

File tree

4 files changed

+22
-57
lines changed

4 files changed

+22
-57
lines changed

07_Create_First_Cosmos_DB_Project/README.md

Lines changed: 17 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,14 @@ This section will cover how to create your first Cosmos DB project. We'll use a
44

55
## Emulator support
66

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).
88

99
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.
1010

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

1313
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).
1414

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-
1715
**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.**
1816

1917
## Authentication
@@ -24,93 +22,60 @@ Authentication to Azure Cosmos DB API for Mongo DB uses a connection string. The
2422

2523
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`.
2624

27-
![The Azure Cosmos DB emulator screen displays with the local host url, the Quickstart tab, and the Mongo connection string highlighted.](media/emulator_connection_string.png)
25+
![The Azure Cosmos DB emulator screen displays with the local host url, the Quickstart tab, and the connection string highlighted.](media/emulator_connection_string.png)
2826

2927
### Retrieving the connection string from the Azure portal
3028

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

33-
![The Azure CosmosDb API for NoSQL Connection strings screen displays with the copy button next to the connection string highlighted.](media/azure_connection_string.png)
31+
![The Azure Cosmos DB API for NoSQL Connection strings screen displays with the copy button next to the connection string highlighted.](media/azure_connection_string.png)
3432

3533
## Lab - Create your first Cosmos DB for the NoSQL application
3634

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

3937
>**Note**: It is highly recommended to use a [virtual environment](https://python.land/virtual-environments/virtualenv) for all labs.
4038
4139
Please visit the lab repository to complete [this lab](../Labs/lab_1_first_application.ipynb).
4240

4341
The following concepts are covered in detail in this lab:
4442

45-
### Creating a MongoDB database client
43+
### Creating a database client
4644

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

4947
```python
50-
client = pymongo.MongoClient(CONNECTION_STRING)
48+
client = cosmos_client.CosmosClient(HOST, {'masterKey': MASTER_KEY} )
5149
```
5250

5351
### Creating a database
5452

55-
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.
5854

5955
```python
60-
db = client.cosmic_works
56+
client.create_database(id=id)
6157
```
6258

6359
### Creating a container
6460

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
7062

7163
### Creating a document
7264

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
77-
product_id = collection.insert_one(product_json).inserted_id
78-
```
65+
In progress
7966

8067
### Reading a document
8168

82-
The `find_one` method is used to retrieve a single document from a container. The method returns a dictionary object.
83-
84-
```python
85-
retrieved_document = collection.find_one({"_id": product_id})
86-
```
69+
In progress
8770

8871
### Updating a document
8972

90-
The `find_one_and_update` method is used to update a single document in a container. The method returns a dictionary object.
91-
92-
```python
93-
update_result = collection.find_one_and_update(
94-
{"_id": product_id},
95-
{"$set": {"name": retrieved_product.name}},
96-
return_document=pymongo.ReturnDocument.AFTER
97-
)
98-
```
73+
In progress
9974

10075
### Deleting a document
10176

102-
The `delete_one` method is used to delete a single document from a container.
103-
104-
```python
105-
delete_result = collection.delete_one({"_id": product_id})
106-
```
77+
In progress
10778

10879
### Querying documents
10980

110-
The `find` method is used to query documents from a container. The method returns a cursor object.
111-
112-
```python
113-
# Print all documents that have a category name of "Components, Saddles"
114-
for result in collection.find({"categoryName": "Components, Saddles"}):
115-
pprint(result)
116-
```
81+
In progress
0 Bytes
Loading

Labs/deploy/deploy.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,7 @@ cd Labs
1919
cd deploy
2020
```
2121

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-
![editing the azuredeploy.parameters.json file with mongoDBPassword parameter highlighted](images/editor-azuredeploy-parameters-json-password.png)
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.
2723

2824
## Login to Azure
2925

@@ -59,3 +55,7 @@ New-AzResourceGroupDeployment -ResourceGroupName cosmos-devguide-rg -TemplateFil
5955
> ````powershell
6056
> Update-AzCosmosDBAccount -ResourceGroupName <resource-group-name> -Name <account-name> -Capabilities @{name="EnableNoSQLVectorSearch"}
6157
> ````
58+
59+
## Enroll with the DiskANN early preview
60+
61+
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.
Binary file not shown.

0 commit comments

Comments
 (0)