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
This `.devcontainer` directory contains the configuration for a [dev container](https://docs.github.com/codespaces/setting-up-your-project-for-codespaces/adding-a-dev-container-configuration/introduction-to-dev-containers). It lets you open the repository in a [GitHub codespace](https://docs.github.com/codespaces/overview).
3
+
This `.devcontainer` directory contains the configuration for a [dev container](https://docs.github.com/codespaces/setting-up-your-project-for-codespaces/adding-a-dev-container-configuration/introduction-to-dev-containers) and isn't used by the sample application.
4
4
5
-
The dev container is configured to have the [Azure Developer CLI](https://learn.microsoft.com/azure/developer/azure-developer-cli/overview), so you can run `azd` commands directly.
5
+
The dev container configuration lets you open the repository in a [GitHub codespace](https://docs.github.com/codespaces/overview) or a dev container in Visual Studio Code. For your convenience, the dev container is configured with the following:
6
+
7
+
- Python
8
+
- PostgreSQL
9
+
- Redis
10
+
-[Azure Developer CLI](https://learn.microsoft.com/azure/developer/azure-developer-cli/overview) (so you can run `azd` commands directly).
// Add the IDs of extensions you want installed when the container is created.
@@ -51,9 +51,9 @@
51
51
}
52
52
}
53
53
},
54
-
// Use 'forwardPorts' to make a list of ports inside the container available locally.
54
+
// Use 'forwardPorts' to make a list of ports inside the container available locally. 5000 is for Flask, 8000 is for Django, and 5432 is for PostgreSQL.
55
55
"forwardPorts": [
56
-
5000, 5432
56
+
8000, 5000, 5432
57
57
],
58
58
// Use 'postCreateCommand' to run commands after the container is created.
Copy file name to clipboardExpand all lines: README.md
+18-54Lines changed: 18 additions & 54 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,64 +16,47 @@ The [requirements.txt](./requirements.txt) has the following packages, all used
16
16
|[python-dotenv](https://pypi.org/project/python-dotenv/)| Read key-value pairs from .env file and set them as environment variables. In this sample app, those variables describe how to connect to the database locally. <br><br> Flask's [dotenv support](https://flask.palletsprojects.com/en/2.1.x/cli/#environment-variables-from-dotenv) sets environment variables automatically from an `.env` file. |
17
17
|[flask_wtf](https://pypi.org/project/Flask-WTF/)| Form rendering, validation, and CSRF protection for Flask with WTForms. Uses CSRFProtect extension. |
18
18
19
-
## Using this project with the Azure Developer CLI (azd)
19
+
## Run the sample
20
20
21
-
This project is designed to work well with the [Azure Developer CLI](https://learn.microsoft.com/azure/developer/azure-developer-cli/overview),
22
-
which makes it easier to develop apps locally, deploy them to Azure, and monitor them.
21
+
This project has a [dev container configuration](.devcontainer/), which makes it easier to develop apps locally, deploy them to Azure, and monitor them. The easiest way to run this sample application is inside a GitHub codespace. Follow these steps:
23
22
24
-
### Local development
23
+
1. Fork this repository to your account. For instructions, see [Fork a repo](https://docs.github.com/get-started/quickstart/fork-a-repo).
25
24
26
-
This project has Dev Container support, so you can open it in Github Codespaces or local VS Code with the Dev Containers extension.
25
+
1. From the repository root of your fork, select **Code** > **Codespaces** > **+**.
27
26
28
-
🎥 [Watch a screencast of running the app in Github Codespaces.](https://www.youtube.com/watch?v=r6Hnp9RXUpY)
29
-
30
-
Steps for running the server:
31
-
32
-
1. (Optional) If you're unable to open the Dev Container, [create a Python virtual environment](https://docs.python.org/3/tutorial/venv.html#creating-virtual-environments) and activate the virtual environment.
33
-
34
-
2. Install the requirements:
27
+
1. In the codespace terminal, run the following commands:
35
28
36
29
```shell
30
+
# Install requirements
37
31
python3 -m pip install -r requirements.txt
38
-
```
39
-
40
-
3. Create an `.env` file using `.env.sample` as a guide. Set the value of `DBNAME` to the name of an existing database in your local PostgreSQL instance. Set the values of `DBHOST`, `DBUSER`, and `DBPASS` as appropriate foryour local PostgreSQL instance. If you'rein the Dev Container, copy the values from `.env.sample.devcontainer`.
41
-
42
-
4. In the `.env` file, fill in a secret value for`SECRET_KEY`. You can use this command to generate an appropriate value:
6. Run the local server: (or use VS Code "Run" button and select"Run server")
55
-
56
-
```shell
36
+
# Start the development server
57
37
python3 -m flask run
58
38
```
59
39
60
-
### Deployment
40
+
1. When you see the message `Your application running on port 8000 is available.`, click **Open in Browser**.
41
+
42
+
### Quick deploy
61
43
62
-
This repo is set up for deployment on Azure App Service (w/PostGreSQL server) using the configuration files in the `infra` folder.
44
+
This project is designed to work well with the [Azure Developer CLI](https://learn.microsoft.com/azure/developer/azure-developer-cli/overview), which makes it easier to develop apps locally, deploy them to Azure, and monitor them.
63
45
64
-
🎥 [Watch a screencast of deploying and re-deploying the app.](https://www.youtube.com/watch?v=r6Hnp9RXUpY)
46
+
🎥 Watch a deployment of the code in [this screencast](https://www
47
+
.youtube.com/watch?v=JDlZ4TgPKYc).
65
48
66
49
Steps for deployment:
67
50
68
51
1. Sign up for a [free Azure account](https://azure.microsoft.com/free/)
69
-
2. Install the [Azure Dev CLI](https://learn.microsoft.com/azure/developer/azure-developer-cli/install-azd). (If you opened this repository in a Dev Container, that part will be done for you.)
52
+
2. Install the [Azure Dev CLI](https://learn.microsoft.com/azure/developer/azure-developer-cli/install-azd). (If you opened this repository in a Dev Container, it's already installed for you.)
70
53
3. Initialize a new `azd` environment:
71
54
72
55
```shell
73
56
azd init
74
57
```
75
58
76
-
It will prompt you to provide a name (like "flask-app") that will later be used in the name of the deployed resources.
59
+
It will prompt you to provide a name (like "flask-app"), which will later be used in the name of the deployed resources.
77
60
78
61
4. Provision and deploy all the resources:
79
62
@@ -93,25 +76,6 @@ Steps for deployment:
93
76
azd deploy
94
77
```
95
78
96
-
### CI/CD pipeline
97
-
98
-
This project includes a Github workflow for deploying the resources to Azure
99
-
on every push. That workflow requires several Azure-related authentication secrets to be stored as Github action secrets. To set that up, run:
100
-
101
-
```shell
102
-
azd pipeline config
103
-
```
104
-
105
-
### Monitoring
106
-
107
-
The deployed resources include a Log Analytics workspace with an Application Insights dashboard to measure metrics like server response time.
108
-
109
-
To open that dashboard, just run:
110
-
111
-
```shell
112
-
azd monitor --overview
113
-
```
114
-
115
79
## Getting help
116
80
117
81
If you're working with this project and running into issues, please post in [Issues](/issues).
0 commit comments