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: samples/web-app-cosmosdb-nosql-api/python/README.md
+9-69Lines changed: 9 additions & 69 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
-
# Azure Web App with Azure CosmosDB for MongoDB
1
+
# Azure Web App with Azure CosmosDB for NoSQL API
2
2
3
-
This sample demonstrates a Python Flask single-page web application called *Vacation Planner* hosted on an [Azure Web App](https://learn.microsoft.com/en-us/azure/app-service/overview). The app runs on an Azure App Service Plan and stores activity data in the `activities`collection of the `sampledb`MongoDB database on an [Azure CosmosDB for MongoDB](https://learn.microsoft.com/en-us/azure/cosmos-db/mongodb/introduction) account.
3
+
This sample demonstrates a Python Flask single-page web application called *Vacation Planner* hosted on an [Azure Web App](https://learn.microsoft.com/en-us/azure/app-service/overview). The app runs on an Azure App Service Plan and stores activity data in the `activities`container of the `sampledb`NoSQL database on an [Azure CosmosDB for NoSQL](https://learn.microsoft.com/en-us/azure/cosmos-db/distributed-nosql) account.
4
4
5
5
## Architecture
6
6
@@ -10,7 +10,7 @@ The following diagram illustrates the architecture of the solution:
10
10
11
11
-**Azure Web App**: Hosts the Python Flask application
12
12
-**Azure App Service Plan**: Provides compute resources for the web app
13
-
-**Azure CosmosDB for MongoDB**: Stores activity data in a MongoDB collection
13
+
-**Azure CosmosDB for NoSQL API**: Stores activity data in a CosmosDB container
14
14
15
15
## Prerequisites
16
16
@@ -19,8 +19,6 @@ The following diagram illustrates the architecture of the solution:
Deploy the application to LocalStack for Azure using one of these methods:
38
+
Deploy the application to LocalStack for Azure using:
41
39
42
40
-[Azure CLI Deployment](./scripts/README.md)
43
-
-[Bicep Deployment](./bicep/README.md)
44
-
-[Terraform Deployment](./terraform/README.md)
45
-
46
-
All deployment methods have been fully tested against Azure and the LocalStack for Azure local emulator.
47
41
48
42
> **Note**
49
43
> When you deploy the application to LocalStack for Azure for the first time, the initialization process involves downloading and building Docker images. This is a one-time operation—subsequent deployments will be significantly faster. Depending on your internet connection and system resources, this initial setup may take several minutes.
@@ -54,7 +48,7 @@ All deployment methods have been fully tested against Azure and the LocalStack f
54
48
2. Open a web browser and navigate to `http://localhost:<published-port>`.
55
49
3. If the deployment was successful, you will see the following user interface for adding and removing activities:
You can use the `call-web-app.sh` Bash script below to call the web app. The script demonstrates three methods for calling web apps:
60
54
@@ -267,70 +261,16 @@ call_web_app() {
267
261
call_web_app
268
262
```
269
263
270
-
## MongoDB Tooling
271
-
272
-
You can utilize [MongoDB Compass](https://www.mongodb.com/try/download/compass) to explore and manage your MongoDB databases and collections. Ensure you connect using `mongodb://localhost:port` connection string, where `port` corresponds to the port published by the MongoDB container on the host and mapped to the internal MongoDB port `27017`.
264
+
## CosmosDB Tooling
273
265
274
-

266
+
You can utilize [CosmosDB Data Explorer] to explore and manage your CosmosDB databases and collections. Ensure you connect using `http://localhost:port` connection string, where `port` corresponds to the port published by the CosmosDB container on the host and mapped to the internal CosmosDB port `1234`.
275
267
276
-
Alternatively, you can use the [MongoDB Shell](https://www.mongodb.com/docs/mongodb-shell/) to interact with and administer your MongoDB instance, as shown in the following table:
277
-
278
-
```bash
279
-
~$ mongosh mongodb://localhost:32770
280
-
Current Mongosh Log ID: 6914588406320f60899dc29c
281
-
Connecting to: mongodb://localhost:32770/?directConnection=true&serverSelectionTimeoutMS=2000&appName=mongosh+2.5.9
282
-
Using MongoDB: 8.0.15
283
-
Using Mongosh: 2.5.9
284
-
285
-
For mongosh info see: https://www.mongodb.com/docs/mongodb-shell/
286
-
287
-
------
288
-
The server generated these startup warnings when booting
289
-
2025-11-12T09:28:07.726+00:00: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine. See http://dochub.mongodb.org/core/prodnotes-filesystem
290
-
2025-11-12T09:28:07.892+00:00: Access control is not enabled for the database. Read and write access to data and configuration is unrestricted
291
-
2025-11-12T09:28:07.892+00:00: For customers running the current memory allocator, we suggest changing the contents of the following sysfsFile
292
-
2025-11-12T09:28:07.892+00:00: We suggest setting the contents of sysfsFile to 0.
293
-
2025-11-12T09:28:07.892+00:00: vm.max_map_count is too low
294
-
2025-11-12T09:28:07.892+00:00: We suggest setting swappiness to 0 or 1, as swapping can cause performance problems.
295
-
------
296
-
297
-
test> show dbs
298
-
admin 100.00 KiB
299
-
config 108.00 KiB
300
-
local 40.00 KiB
301
-
sampledb 180.00 KiB
302
-
test> use sampledb
303
-
switched to db sampledb
304
-
sampledb> show collections
305
-
activities
306
-
sampledb>db.activities.find().pretty()
307
-
[
308
-
{
309
-
_id: '39ab62c2aaa0015ed5309876053e4146',
310
-
username: 'Paolo',
311
-
activity: 'Go to Paris',
312
-
timestamp: '2025-11-12T09:31:43.338268'
313
-
},
314
-
{
315
-
_id: '4fb8f53442d3ebe9167245f9555bac51',
316
-
username: 'Paolo',
317
-
activity: 'Go to Madrid',
318
-
timestamp: '2025-11-12T09:31:50.109456'
319
-
},
320
-
{
321
-
_id: '84646160cb1db21a7083b4c5b6e2d9d0',
322
-
username: 'Paolo',
323
-
activity: 'Go to Rome',
324
-
timestamp: '2025-11-12T09:32:21.781936'
325
-
}
326
-
]
327
-
```
268
+

328
269
329
270
## References
330
271
331
272
-[Azure Web Apps Documentation](https://learn.microsoft.com/en-us/azure/app-service/)
332
-
-[Azure CosmosDB for MongoDB API](https://learn.microsoft.com/en-us/azure/cosmos-db/mongodb/introduction)
273
+
-[Azure CosmosDB for MongoDB API](https://learn.microsoft.com/en-us/azure/cosmos-db/)
333
274
-[Quickstart: Python Flask on Azure](https://learn.microsoft.com/en-us/azure/app-service/quickstart-python?tabs=flask%2Cbrowser)
334
-
-[Quickstart: CosmosDB for MongoDB](https://learn.microsoft.com/en-us/azure/cosmos-db/mongodb/quickstart?tabs=azure-portal)
335
275
-[Azure Identity Client Library for Python](https://learn.microsoft.com/en-us/python/api/overview/azure/identity-readme?view=azure-python)
336
276
-[LocalStack for Azure](https://azure.localstack.cloud/)
0 commit comments