|
1 | | -# Create your first Cosmos DB project (console app (Jupyter notebook?)) |
| 1 | +# Create your first Cosmos DB project |
2 | 2 |
|
3 | | -- How to use the Cosmos DB SDK |
4 | | -- How to develop locally |
| 3 | +In this section, we'll cover how to create your first Cosmos DB project. We'll use a notebook to demonstrate the basic CRUD operations. We'll also cover how to use the Azure Cosmos DB Emulator to test your code locally. |
5 | 4 |
|
6 | | -## Emulator support (does it support vector search?) |
7 | | -## Authentication options |
8 | | -## Create a database |
9 | | -## Create a collection |
10 | | -## Create a document |
| 5 | +## Emulator support |
11 | 6 |
|
12 | | -## INCLUDE 08_Load_Data here |
| 7 | +Azure Cosmos DB has an emulator that you can use to develop your code locally. The emulator supports the API for NoSQL and API for MongoDB. Usage of the emulator does not require an Azure Subscription nor does it incur any costs so 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/en-us/azure/cosmos-db/how-to-develop-emulator?tabs=windows%2Cpython&pivots=api-mongodb#use-the-emulator-in-a-github-actions-ci-workflow). |
13 | 8 |
|
14 | | -## Read a document |
15 | | -## Update a document |
16 | | -## Delete a document |
17 | | -## Query documents |
| 9 | +There is not 100% feature parity between the emulator and the cloud service. Visit the [Azure Cosmos DB emulator](https://learn.microsoft.com/en-us/azure/cosmos-db/emulator) documentation for more details. |
18 | 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. |
| 12 | + |
| 13 | +Learn more about the pre-requisites and installation of the emulator [here](https://learn.microsoft.com/en-us/azure/cosmos-db/how-to-develop-emulator?tabs=windows%2Cpython&pivots=api-mongodb). |
| 14 | + |
| 15 | +## Authentication |
| 16 | + |
| 17 | +Authentication to Azure Cosmos DB API for Mongo DB is done using a connection string. The connection string is a URL that contains the authentication information for your Azure Cosmos DB account or local emulator. The username and password used when provisioning the Azure Cosmos DB API for MongoDB service are used in the connection string when authenticating to Azure. |
| 18 | + |
| 19 | +### Retrieving the connection string from the Cosmos DB Emulator |
| 20 | + |
| 21 | +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`. |
| 22 | + |
| 23 | + |
| 24 | + |
| 25 | +### Retrieving the connection string from the Azure portal |
| 26 | + |
| 27 | +Retrieve the connection string from the Azure portal by navigating to your 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 an password that must be replaced with the username and password used when provisioning the Azure Cosmos DB API for MongoDB service. Additional users can be added at any time using the [Azure CLI](https://learn.microsoft.com/en-us/cli/azure/cosmosdb/mongodb/user?view=azure-cli-latest). |
| 28 | + |
| 29 | + |
| 30 | + |
| 31 | +## Authorization |
| 32 | + |
| 33 | +Azure Cosmos DB API for MongoDB supports fine-grained role-based access control (RBAC) for authorization. There are a number of built-in roles available. The built-in roles are: |
| 34 | + 1. read |
| 35 | + 2. readWrite |
| 36 | + 3. dbAdmin |
| 37 | + 4. dbOwner |
| 38 | + |
| 39 | +The ability to create custom roles is also available. Custom roles can be created using the [Azure CLI](https://learn.microsoft.com/en-us/azure/cosmos-db/mongodb/how-to-setup-rbac). Custom roles can include granular permissions for specific databases, collections, and operational actions. Learn more about the [Azure CLI RBAC commands to define custom roles](https://learn.microsoft.com/en-us/azure/cosmos-db/mongodb/how-to-setup-rbac#azure-cli-rbac-commands). |
| 40 | + |
| 41 | +## Helpful tools |
| 42 | + |
| 43 | +Visualization and querying tools: |
| 44 | + 1. Studio 3T |
| 45 | + 2. MongoDB Compass |
| 46 | + 3. Azure Data Studio |
| 47 | + 4. MongoDB Shell |
| 48 | + 5. Azure Portal Data Explorer |
| 49 | + |
| 50 | +## Lab 1 - Create your first Cosmos DB for MongoDB application |
| 51 | + |
| 52 | +In this lab, we'll create a Cosmos DB for MongoDB application using a notebook. You have the choice to either use the Azure Cosmos DB Emulator or an Azure Cosmos DB account in Azure. The following concepts will be covered in this lab: |
| 53 | + 1. Create a database |
| 54 | + 2. Create a collection |
| 55 | + 3. Create a document |
| 56 | + 4. Read a document |
| 57 | + 5. Update a document |
| 58 | + 6. Delete a document |
| 59 | + 7. Query documents |
| 60 | + |
| 61 | +Please visit the lab repository to complete this lab. |
0 commit comments