Skip to content

Commit 7699a29

Browse files
Merge pull request #102476 from v-thepet/quickstarts5
Three Cosmos DB MongoDB quickstarts
2 parents 41ec763 + 296802a commit 7699a29

File tree

6 files changed

+59
-71
lines changed

6 files changed

+59
-71
lines changed

articles/cosmos-db/create-mongodb-flask.md

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,13 @@ ms.date: 12/26/2018
2121
> * [Golang](create-mongodb-golang.md)
2222
>
2323
24-
Azure Cosmos DB is Microsoft’s globally distributed multi-model database service. You can quickly create and query document, key/value, and graph databases, all of which benefit from the global distribution and horizontal scale capabilities at the core of Cosmos DB.
25-
26-
This quickstart guide uses the following [Flask example](https://github.com/Azure-Samples/CosmosDB-Flask-Mongo-Sample) and demonstrates how to build a simple To-Do Flask app with the [Azure Cosmos DB Emulator](local-emulator.md) and the Azure Cosmos DB's API for MongoDB.
24+
In this quickstart, you use an Azure Cosmos DB for Mongo DB API account or the Azure Cosmos DB Emulator to run a Python Flask To-Do web app cloned from GitHub. Azure Cosmos DB is a multi-model database service that lets you quickly create and query document, table, key-value, and graph databases with global distribution and horizontal scale capabilities.
2725

2826
## Prerequisites
2927

30-
- Download the [Azure Cosmos DB Emulator](local-emulator.md). The emulator is currently only supported on Windows. The sample shows how to use the sample with a production key from Azure, which can be done on any platform.
31-
32-
- If you don’t already have Visual Studio Code installed, you can quickly install [VS Code](https://code.visualstudio.com/Download) for your platform (Windows, Mac, Linux).
33-
34-
- Be sure to add Python Language support by installing one of the popular Python extensions.
35-
1. Select an extension.
36-
2. Install the extension by typing `ext install` into the Command Palette `Ctrl+Shift+P`.
37-
38-
The examples in this document use Don Jayamanne's popular and full featured [Python Extension](https://marketplace.visualstudio.com/items?itemName=donjayamanne.python).
28+
- An Azure account with an active subscription. [Create one for free](https://azure.microsoft.com/free/?ref=microsoft.com&utm_source=microsoft.com&utm_medium=docs&utm_campaign=visualstudio). Or [try Azure Cosmos DB for free](https://azure.microsoft.com/try/cosmosdb/) without an Azure subscription. Or, you can use the [Azure Cosmos DB Emulator](local-emulator.md).
29+
- [Python 3.6+](https://www.python.org/downloads/)
30+
- [Visual Studio Code](https://code.visualstudio.com/Download) with the [Python Extension](https://marketplace.visualstudio.com/items?itemName=donjayamanne.python).
3931

4032
## Clone the sample application
4133

@@ -69,7 +61,7 @@ Now let's clone a Flask-MongoDB app from GitHub, set the connection string, and
6961

7062
This step is optional. If you're interested in learning how the database resources are created in the code, you can review the following snippets. Otherwise, you can skip ahead to [Run the web app](#run-the-web-app).
7163
72-
The following snippets are all taken from the app.py file and uses the connection string for the local Azure Cosmos DB Emulator. The password needs to be split up as seen below to accommodate for the forward slashes that cannot be parsed otherwise.
64+
The following snippets are all taken from the *app.py* file and uses the connection string for the local Azure Cosmos DB Emulator. The password needs to be split up as seen below to accommodate for the forward slashes that cannot be parsed otherwise.
7365
7466
* Initialize the MongoDB client, retrieve the database, and authenticate.
7567
@@ -101,29 +93,31 @@ The following snippets are all taken from the app.py file and uses the connectio
10193
10294
3. Then set the environment variable for the Flask app with `set FLASK_APP=app.py`, `$env:FLASK_APP = app.py` for PowerShell editors, or `export FLASK_APP=app.py` if you are using a Mac.
10395
104-
4. Run the app with `flask run` and browse to [http://127.0.0.1:5000/](http://127.0.0.1:5000/).
96+
4. Run the app with `flask run` and browse to *http:\//127.0.0.1:5000/*.
10597
10698
5. Add and remove tasks and see them added and changed in the collection.
10799
108100
## Create a database account
109101
102+
If you want to test the code against a live Azure Cosmos DB account, go to the Azure portal to create an account.
103+
110104
[!INCLUDE [cosmos-db-create-dbaccount](../../includes/cosmos-db-create-dbaccount-mongodb.md)]
111105
112106
## Update your connection string
113107
114-
If you want to test the code against a live Cosmos Account, go to the Azure portal to create an account and get your connection string information. Then copy it into the app.
108+
To test the code against the live Azure Cosmos DB account, get your connection string information. Then copy it into the app.
115109
116-
1. In the [Azure portal](https://portal.azure.com/), in your Cosmos account, in the left navigation click **Connection String**, and then click **Read-write Keys**. You'll use the copy buttons on the right side of the screen to copy the Username, Password, and Host into the Dal.cs file in the next step.
110+
1. In your Azure Cosmos DB account in the Azure portal, in the left navigation select **Connection String**, and then select **Read-write Keys**. You'll use the copy buttons on the right side of the screen to copy the username, connection string, and password.
117111

118-
2. Open the **app.py** file in the root directory.
112+
2. Open the *app.py* file in the root directory.
119113

120-
3. Copy your **username** value from the portal (using the copy button) and make it the value of the **name** in your **app.py** file.
114+
3. Copy your **username** value from the portal (using the copy button) and make it the value of the **name** in your *app.py* file.
121115

122-
4. Then copy your **connection string** value from the portal and make it the value of the MongoClient in your **app.py** file.
116+
4. Then copy your **connection string** value from the portal and make it the value of the **MongoClient** in your *app.py* file.
123117

124-
5. Finally copy your **password** value from the portal and make it the value of the **password** in your **app.py** file.
118+
5. Finally copy your **password** value from the portal and make it the value of the **password** in your *app.py* file.
125119

126-
You've now updated your app with all the info it needs to communicate with Cosmos DB. You can run it the same way as before.
120+
You've now updated your app with all the info it needs to communicate with Azure Cosmos DB. You can run it the same way as before.
127121
128122
## Deploy to Azure
129123
@@ -139,7 +133,7 @@ When deploying to Azure, you should remove your application keys and make sure t
139133
140134
You then need to add your MONGOURL, MONGO_PASSWORD, and MONGO_USERNAME to the application settings. You can follow this [tutorial](https://docs.microsoft.com/azure/app-service/configure-common#configure-app-settings) to learn more about Application Settings in Azure Web Apps.
141135
142-
If you don't want to create a fork of this repo, you can also click the deploy to Azure button below. You should then go into Azure and set up the application settings with your Cosmos DB account info.
136+
If you don't want to create a fork of this repo, you can also select the **Deploy to Azure** button below. You should then go into Azure and set up the application settings with your Azure Cosmos DB account info.
143137

144138
<a href="https://deploy.azure.com/?repository=https://github.com/heatherbshapiro/To-Do-List---Flask-MongoDB-Example" target="_blank">
145139
<img src="https://azuredeploy.net/deploybutton.png" alt="Click to Deploy to Azure">
@@ -158,7 +152,7 @@ If you don't want to create a fork of this repo, you can also click the deploy t
158152

159153
## Next steps
160154

161-
In this quickstart, you've learned how to create a Cosmos account and run a Flask app. You can now import additional data to your Cosmos database.
155+
In this quickstart, you learned how to create an Azure Cosmos DB for Mongo DB API account, and use the Azure Cosmos DB Emulator to run a Python Flask To-Do web app cloned from GitHub. You can now import additional data to your Azure Cosmos DB account.
162156

163157
> [!div class="nextstepaction"]
164158
> [Import MongoDB data into Azure Cosmos DB](mongodb-migrate.md)

articles/cosmos-db/create-mongodb-java.md

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,26 +22,21 @@ ms.custom: seo-java-august2019, seo-java-september2019
2222
> * [Golang](create-mongodb-golang.md)
2323
>
2424
25-
In this quickstart, you'll use the Azure Cosmos DB API for Mongo DB and Java SDK to create a console web app. Azure Cosmos DB allows you to quickly create and query document, key/value and graph databases, all of which benefit from the global distribution and horizontal scale capabilities at the core of Cosmos DB.
26-
27-
This quickstart demonstrates how to create a Cosmos account with [Azure Cosmos DB's API for MongoDB](mongodb-introduction.md). You'll then build and deploy a console app built using the [MongoDB Java driver](https://docs.mongodb.com/ecosystem/drivers/java/).
25+
In this quickstart, you create and manage an Azure Cosmos DB for MongoDB API account from the Azure portal, and add data by using a Java SDK app cloned from GitHub. Azure Cosmos DB is a multi-model database service that lets you quickly create and query document, table, key-value, and graph databases with global distribution and horizontal scale capabilities.
2826

2927
## Prerequisites
30-
31-
Before you can run this sample, you must have the following prerequisites:
32-
* [Install the JDK for Azure and Azure Stack JDK version 8](https://aka.ms/azure-jdks)
33-
* Maven (Run `apt-get install maven` if you don't have Maven)
34-
35-
[!INCLUDE [quickstarts-free-trial-note](../../includes/quickstarts-free-trial-note.md)]
36-
[!INCLUDE [cosmos-db-emulator-mongodb](../../includes/cosmos-db-emulator-mongodb.md)]
28+
- An Azure account with an active subscription. [Create one for free](https://azure.microsoft.com/free/?ref=microsoft.com&utm_source=microsoft.com&utm_medium=docs&utm_campaign=visualstudio). Or [try Azure Cosmos DB for free](https://azure.microsoft.com/try/cosmosdb/) without an Azure subscription. You can also use the [Azure Cosmos DB Emulator](https://aka.ms/cosmosdb-emulator) with the connection string `.mongodb://localhost:C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==@localhost:10255/admin?ssl=true`.
29+
- [Java Development Kit (JDK) version 8](https://www.azul.com/downloads/azure-only/zulu/?&version=java-8-lts&architecture=x86-64-bit&package=jdk).
30+
- [Maven](https://maven.apache.org/download.cgi). Or run `apt-get install maven` to install Maven.
31+
- [Git](https://git-scm.com/downloads).
3732

3833
## Create a database account
3934

4035
[!INCLUDE [mongodb-create-dbaccount](../../includes/cosmos-db-create-dbaccount-mongodb.md)]
4136

4237
## Add a collection
4338

44-
Name your new database, **db**, and your new collection, **coll**.
39+
Name your new database **db**, and your new collection **coll**.
4540

4641
[!INCLUDE [cosmos-db-create-collection](../../includes/cosmos-db-create-collection.md)]
4742

@@ -73,7 +68,9 @@ Now let's clone an app from GitHub, set the connection string, and run it. You'l
7368

7469
This step is optional. If you're interested in learning how the database resources are created in the code, you can review the following snippets. Otherwise, you can skip ahead to [Update your connection string](#update-your-connection-string).
7570
76-
The following snippets are all taken from the Program.java file.
71+
The following snippets are all taken from the *Program.java* file.
72+
73+
This console app uses the [MongoDB Java driver](https://docs.mongodb.com/ecosystem/drivers/java/).
7774
7875
* The DocumentClient is initialized.
7976
@@ -109,9 +106,9 @@ The following snippets are all taken from the Program.java file.
109106
110107
Now go back to the Azure portal to get your connection string information and copy it into the app.
111108
112-
1. From the Account, select **Quick Start**, select **Java**, then copy the connection string to your clipboard.
109+
1. From your Azure Cosmos DB account, select **Quick Start**, select **Java**, then copy the connection string to your clipboard.
113110
114-
2. Open the `Program.java` file, replace the argument to the MongoClientURI constructor with the connection string. You've now updated your app with all the info it needs to communicate with Azure Cosmos DB.
111+
2. Open the *Program.java* file, replace the argument to the MongoClientURI constructor with the connection string. You've now updated your app with all the info it needs to communicate with Azure Cosmos DB.
115112

116113
## Run the console app
117114

@@ -131,7 +128,7 @@ You can now use [Robomongo](mongodb-robomongo.md) / [Studio 3T](mongodb-mongoche
131128

132129
## Next steps
133130

134-
In this quickstart, you've learned how to create a Cosmos account, create a collection and run a console app. You can now import additional data to your Cosmos database.
131+
In this quickstart, you learned how to create an Azure Cosmos DB API for Mongo DB account, add a database and container using Data Explorer, and add data using a Java console app. You can now import additional data to your Cosmos database.
135132

136133
> [!div class="nextstepaction"]
137134
> [Import MongoDB data into Azure Cosmos DB](mongodb-migrate.md)

articles/cosmos-db/create-mongodb-nodejs.md

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -22,27 +22,16 @@ ms.custom: seo-javascript-september2019, seo-javascript-october2019
2222
> * [Golang](create-mongodb-golang.md)
2323
>
2424
25-
This quickstart demonstrates how to use an existing MongoDB app written in Node.js and connect it to your Azure Cosmos database, which supports MongoDB client. In other words, it is transparent to the application that the data is stored in a Cosmos database.
26-
27-
Azure Cosmos DB is Microsoft’s globally distributed multi-model database service. You can quickly create and query document, key/value, and graph databases, all of which benefit from the global distribution and horizontal scale capabilities at the core of Cosmos DB.
28-
29-
When you are done, you will have a MEAN application (MongoDB, Express, Angular, and Node.js) running on [Cosmos DB](https://azure.microsoft.com/services/cosmos-db/).
30-
31-
![MEAN.js app running in Azure App Service](./media/create-mongodb-nodejs/meanjs-in-azure.png)
25+
In this quickstart, you create and manage an Azure Cosmos DB for Mongo DB API account by using the Azure Cloud Shell, and with a MEAN (MongoDB, Express, Angular, and Node.js) app cloned from GitHub. Azure Cosmos DB is a multi-model database service that lets you quickly create and query document, table, key-value, and graph databases with global distribution and horizontal scale capabilities.
3226

27+
## Prerequisites
28+
- An Azure account with an active subscription. [Create one for free](https://azure.microsoft.com/free/?ref=microsoft.com&utm_source=microsoft.com&utm_medium=docs&utm_campaign=visualstudio). Or [try Azure Cosmos DB for free](https://azure.microsoft.com/try/cosmosdb/) without an Azure subscription. You can also use the [Azure Cosmos DB Emulator](https://aka.ms/cosmosdb-emulator) with the connection string `.mongodb://localhost:C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==@localhost:10255/admin?ssl=true`.
29+
- [Node.js](https://nodejs.org/), and a working knowledge of Node.js.
30+
- [Git](https://git-scm.com/downloads).
31+
- If you don't want to use Azure Cloud Shell, [Azure CLI 2.0+](/cli/azure/install-azure-cli).
3332

3433
[!INCLUDE [cloud-shell-try-it](../../includes/cloud-shell-try-it.md)]
3534

36-
If you choose to install and use the CLI locally, this topic requires that you are running the Azure CLI version 2.0 or later. Run `az --version` to find the version. If you need to install or upgrade, see [Install Azure CLI]( /cli/azure/install-azure-cli).
37-
38-
## Prerequisites
39-
If you don't have an Azure subscription, create a [free account](https://azure.microsoft.com/free/?WT.mc_id=A261C142F) before you begin.
40-
[!INCLUDE [cosmos-db-emulator-mongodb](../../includes/cosmos-db-emulator-mongodb.md)]
41-
42-
In addition to Azure CLI, you need [Node.js](https://nodejs.org/) and [Git](https://www.git-scm.com/downloads) installed locally to run `npm` and `git` commands.
43-
44-
You should have working knowledge of Node.js. This quickstart is not intended to help you with developing Node.js applications in general.
45-
4635
## Clone the sample application
4736

4837
Run the following commands to clone the sample repository. This sample repository contains the default [MEAN.js](https://meanjs.org/) application.
@@ -67,6 +56,8 @@ Run the following commands to clone the sample repository. This sample repositor
6756

6857
## Run the application
6958

59+
This MongoDB app written in Node.js connects to your Azure Cosmos DB database, which supports MongoDB client. In other words, it is transparent to the application that the data is stored in an Azure Cosmos DB database.
60+
7061
Install the required packages and start the application.
7162

7263
```bash
@@ -76,9 +67,11 @@ npm start
7667
```
7768
The application will try to connect to a MongoDB source and fail, go ahead and exit the application when the output returns "[MongoError: connect ECONNREFUSED 127.0.0.1:27017]".
7869

79-
## Log in to Azure
70+
## Sign in to Azure
71+
72+
If you choose to install and use the CLI locally, this topic requires that you are running the Azure CLI version 2.0 or later. Run `az --version` to find the version. If you need to install or upgrade, see [Install Azure CLI].
8073

81-
If you are using an installed Azure CLI, log in to your Azure subscription with the [az login](/cli/azure/reference-index#az-login) command and follow the on-screen directions. You can skip this step if you're using the Azure Cloud Shell.
74+
If you are using an installed Azure CLI, sign in to your Azure subscription with the [az login](/cli/azure/reference-index#az-login) command and follow the on-screen directions. You can skip this step if you're using the Azure Cloud Shell.
8275
8376
```azurecli
8477
az login
@@ -88,7 +81,7 @@ az login
8881
8982
If you are using an installed Azure CLI, check to see if the `cosmosdb` component is already installed by running the `az` command. If `cosmosdb` is in the list of base commands, proceed to the next command. You can skip this step if you're using the Azure Cloud Shell.
9083

91-
If `cosmosdb` is not in the list of base commands, reinstall [Azure CLI]( /cli/azure/install-azure-cli).
84+
If `cosmosdb` is not in the list of base commands, reinstall [Azure CLI](/cli/azure/install-azure-cli).
9285

9386
## Create a resource group
9487

@@ -153,7 +146,7 @@ DB/databaseAccounts/<cosmosdb-name>",
153146

154147
## Connect your Node.js application to the database
155148

156-
In this step, you connect your MEAN.js sample application to Cosmos database you just created.
149+
In this step, you connect your MEAN.js sample application to the Azure Cosmos DB database account you just created.
157150

158151
<a name="devconfig"></a>
159152
## Configure the connection string in your Node.js application
@@ -248,7 +241,7 @@ git commit -m "configured MongoDB connection string"
248241

249242
## Next steps
250243

251-
In this quickstart, you've learned how to create a Cosmos account, create a collection and run a console app. You can now import additional data to your Cosmos database.
244+
In this quickstart, you learned how to create an Azure Cosmos DB MongoDB API account using the Azure Cloud Shell, and create and run a MEAN.js app to add users to the account. You can now import additional data to your Azure Cosmos DB account.
252245

253246
> [!div class="nextstepaction"]
254247
> [Import MongoDB data into Azure Cosmos DB](mongodb-migrate.md)

0 commit comments

Comments
 (0)