|
1 |
| -# Project Name |
| 1 | +# Deploy a Python (Django) web app container to Azure App Service (in progress) |
2 | 2 |
|
3 |
| -(short, 1-3 sentenced, description of the project) |
| 3 | +This Python web app is a restaurant review application using the [Django](https://www.djangoproject.com/) framework. The app is intended to be used as a container running on Azure App Service with a connection to an Azure Cosmos DB API for MongoDB. |
4 | 4 |
|
5 |
| -## Features |
| 5 | +Following the tutorial [TBD: coming soon](TBD), you can deploy this web app Azure, hosted in a fully managed Azure App Service. Azure managed identity enables the App Service to pull container images from an Azure Container Registry. MongoDB connection info is passed to the code through environment variables. |
6 | 6 |
|
7 |
| -This project framework provides the following features: |
| 7 | +If you need an Azure account, you can [create on for free](https://azure.microsoft.com/free/). |
8 | 8 |
|
9 |
| -* Feature 1 |
10 |
| -* Feature 2 |
11 |
| -* ... |
| 9 | +A Flask sample application with similar functionality is at [TBD: coming soon](TBD). |
12 | 10 |
|
13 |
| -## Getting Started |
| 11 | +## Run and deploy options |
14 | 12 |
|
15 |
| -### Prerequisites |
| 13 | +Here are some ways you can run the sample web app in this repository. |
16 | 14 |
|
17 |
| -(ideally very short, if any) |
| 15 | +| Scenario | As-is repo code | Containerized app | |
| 16 | +| ----------- | ----------- | ----------| |
| 17 | +| Local environment | Run repo code in virtual environment with *requirements.txt*. Set environment variables in shell before running. | Build image from repo and run locally in Docker container. Pass environment variables in Docker CLI command or with VS Code task definition <sup>1<sup>. | |
| 18 | +| Azure App Service [Web App for Containers](https://azure.microsoft.com/services/app-service/containers/) | Deploy repo code to App service. Set environment variables as App Service configuration settings. See note about subpath. <sup>2</sup> | Build image locally or in Azure and push to container registry like Azure Container Registry. Configure App Service to pull from registry. Set environment variables as App Service configuration settings. | |
| 19 | +| [Azure Container Apps](https://docs.microsoft.com/azure/container-apps/overview) | *n/a* | Build image locally or in Azure and push to container registry like Azure Container Registry. Create a Container App with deployment from the registry. Configure environment variables for the container. | |
18 | 20 |
|
19 |
| -- OS |
20 |
| -- Library version |
21 |
| -- ... |
| 21 | +(1) The *.vscode* directory *settings.json* and *tasks.json* are configured either for a MongoDB local connection or an Azure Cosmos DB connection. The tasks and templates in *.vscode* are only used when using Visual Studio Code locally. |
22 | 22 |
|
23 |
| -### Installation |
| 23 | +(2) This app was designed to be containerized and run on App Service. If you want to deploy to App Service without containerizing it, then be sure to set the *subpath* to the *azureporject* folder, which contains the *manage.py* file. Do that by: |
24 | 24 |
|
25 |
| -(ideally very short) |
| 25 | +* In VS Code: **F1** or **CTRL** + **SHIFT** + **P** to open the command palette. |
| 26 | +* Type "Preferences: Open Workspace Settings" and select to open. |
| 27 | +* In the Settings search field, enter "@id:appService.deploySubpath appser". |
| 28 | +* Set the subpath as "azureproject". |
26 | 29 |
|
27 |
| -- npm install [package name] |
28 |
| -- mvn install |
29 |
| -- ... |
30 | 30 |
|
31 |
| -### Quickstart |
32 |
| -(Add steps to get up and running quickly) |
| 31 | +## Environment variables |
33 | 32 |
|
34 |
| -1. git clone [repository clone url] |
35 |
| -2. cd [repository name] |
36 |
| -3. ... |
| 33 | +The sample code requires the following environment variables passed in as described in the scenario table above. |
37 | 34 |
|
| 35 | +``` |
| 36 | +CONNECTION_STRING=<connection-string> |
| 37 | +DB_NAME=restaurants_reviews |
| 38 | +COLLECTION_NAME=restaurants_reviews |
| 39 | +``` |
38 | 40 |
|
39 |
| -## Demo |
| 41 | +For a local MongoDB instance, the connection string is of the form `mongodb://127.0.0.1:27017`. An Azure Cosmos DB API for MongoDB connections string is of the form `mongodb://<server-name>:<password>@<server-name>.mongo.cosmos.azure.com:10255/?ssl=true&<other-parameters>`. |
40 | 42 |
|
41 |
| -A demo app is included to show how to use the project. |
| 43 | +## Requirements |
42 | 44 |
|
43 |
| -To run the demo, follow these steps: |
| 45 | +The [requirements.txt](./requirements.txt) has the following packages: |
44 | 46 |
|
45 |
| -(Add steps to start up the demo) |
| 47 | +| Package | Description | |
| 48 | +| ------- | ----------- | |
| 49 | +| [Django](https://pypi.org/project/Django/) | Web application framework. | |
| 50 | +| [gunicorn](https://pypi.org/project/gunicorn/) | Gunicorn ‘Green Unicorn’ is a Python WSGI HTTP Server for UNIX. | |
| 51 | +| [pymongo](https://pypi.org/project/pymongo/) | The PyMongo distribution contains tools for interacting with MongoDB database from Python. | |
| 52 | +| [requests](https://pypi.org/project/requests/) | An HTTP library | |
| 53 | +| [whitenoise](https://pypi.org/project/whitenoise/) | Static file serving for WSGI applications, used in the deployed app. <br><br> This package is used in the [azureproject/settings.py](./azureproject/azureproject/settings.py) file. | |
46 | 54 |
|
47 |
| -1. |
48 |
| -2. |
49 |
| -3. |
50 |
| - |
51 |
| -## Resources |
52 |
| - |
53 |
| -(Any additional resources or related projects) |
54 |
| - |
55 |
| -- Link to supporting information |
56 |
| -- Link to similar sample |
57 |
| -- ... |
0 commit comments