|
4 | 4 | "cell_type": "markdown", |
5 | 5 | "metadata": {}, |
6 | 6 | "source": [ |
7 | | - "# First Cosmos DB for NoSQL application" |
| 7 | + "# First Azure Cosmos DB for NoSQL application" |
8 | 8 | ] |
9 | 9 | }, |
10 | 10 | { |
|
28 | 28 | "source": [ |
29 | 29 | "## Create a database\n", |
30 | 30 | "\n", |
31 | | - "Ensure the Cosmos DB account connection string is located in a `.env` file in the root of the project, you will need to create this file. The `.env` file should contain the following value (replace the value with your own connection string):\n", |
| 31 | + "Ensure the Azure Cosmos DB account connection string is located in a `.env` file in the root of the project, you will need to create this file. The `.env` file should contain the following value (replace the value with your own connection string):\n", |
32 | 32 | "\n", |
33 | 33 | "COSMOS_DB_CONNECTION_STRING=\"cosmos__db__connection_string\"\n", |
34 | 34 | "\n", |
35 | 35 | ">**Note**: If you are running using the **local emulator**, append the following value to the connection string: `&retrywrites=false&tlsallowinvalidcertificates=true`.\n", |
36 | 36 | "\n", |
37 | | - "To create a NoSQL database in Cosmos DB, first instantiate a `CosmosClient` object, use the `create_database_if_not_exists` method to create a database if it does not exist to avoid any exceptions should the database already exist. This method will create a database with the specified name if it does not exist, otherwise it will return the existing database." |
| 37 | + "To create a NoSQL database in Azure Cosmos DB, first instantiate a `CosmosClient` object, use the `create_database_if_not_exists` method to create a database if it does not exist to avoid any exceptions should the database already exist. This method will create a database with the specified name if it does not exist, otherwise it will return the existing database." |
38 | 38 | ] |
39 | 39 | }, |
40 | 40 | { |
|
46 | 46 | "load_dotenv()\n", |
47 | 47 | "CONNECTION_STRING = os.environ.get(\"COSMOS_DB_CONNECTION_STRING\")\n", |
48 | 48 | "\n", |
49 | | - "# Initialize the Cosmos DB client\n", |
| 49 | + "# Initialize the Azure Cosmos DB client\n", |
50 | 50 | "client = CosmosClient.from_connection_string(CONNECTION_STRING)\n", |
51 | 51 | "\n", |
52 | 52 | "# Create or load the cosmic_works database\n", |
|
83 | 83 | "source": [ |
84 | 84 | "## Create or Update a document (Upsert)\n", |
85 | 85 | "\n", |
86 | | - "Documents in Cosmos DB for NoSQL API are represented as JSON objects. In this lab, the Pydantic library is used to create a model for the document. This model is then used to create a document in the database using built-in serialization methods. Find the models in the `models` folder. Notice the class property definitions include aliases, these aliases can be used to override the serialized property names. This is useful when the property names in the model do not match the property names desired in the database.\n", |
| 86 | + "Documents in Azure Cosmos DB for NoSQL API are represented as JSON objects. In this lab, the Pydantic library is used to create a model for the document. This model is then used to create a document in the database using built-in serialization methods. Find the models in the `models` folder. Notice the class property definitions include aliases, these aliases can be used to override the serialized property names. This is useful when the property names in the model do not match the property names desired in the database.\n", |
87 | 87 | "\n", |
88 | 88 | "One method of creating a document is using the `create_item` method. This method takes a single document and inserts it into the database, if the item already exists in the container, and exception is thrown. Alternatively, the `upsert_item` method can also be used to insert a document into the database and in this case, if the document already exists, it will be updated." |
89 | 89 | ] |
|
145 | 145 | "retrieved_product = query_item_by_id(container, product.id, Product)\n", |
146 | 146 | "\n", |
147 | 147 | "# Print the retrieved product\n", |
148 | | - "print(\"\\nCast Product from document retrieved from Cosmos DB:\")\n", |
| 148 | + "print(\"\\nCast Product from document retrieved from Azure Cosmos DB:\")\n", |
149 | 149 | "print(retrieved_product)" |
150 | 150 | ] |
151 | 151 | }, |
|
0 commit comments