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
@@ -29,7 +28,7 @@ In this tutorial, you learn how to:
29
28
> * View diagnostic logs
30
29
> * Manage the web app in the Azure portal
31
30
32
-
You can follow the steps in this article on macOS, Linux, or Windows. The steps are similar in most cases, but differences aren't detailed in this tutorial. Most of the examples below use a `bash` terminal window on Linux.
31
+
You can follow the steps in this article on macOS, Linux, or Windows. The steps are similar in most cases, although differences aren't detailed in this tutorial. Most of the examples below use a `bash` terminal window on Linux.
33
32
34
33
## Prerequisites
35
34
@@ -42,18 +41,18 @@ Before you start this tutorial:
42
41
43
42
## Connect to your local PostgreSQL server and create a database
44
43
45
-
First, create and connect to a local PostgreSQL server and database.
44
+
First, create and connect to a local PostgreSQL server and database:
46
45
47
46
In a local terminal window, run `psql` to connect to your local PostgreSQL server as the built-in `postgres` user.
48
47
49
48
```bash
50
49
psql -U postgres
51
50
```
52
51
53
-
If the connection isn't successful, make sure your PostgreSQL server is running, or start it if necessary by running a command like:
52
+
If the connection isn't successful, make sure your PostgreSQL server is running, or restart it if necessary by running a command like:
54
53
55
54
```bash
56
-
postgres -D /usr/local/pgsql/data
55
+
pg_ctl.exe restart -D "<postgresql data directory>"
57
56
```
58
57
59
58
In your *postgres* directory, create a new database called *pollsdb*, and set up a new database user named *manager* with password *supersecretpass*:
@@ -72,11 +71,11 @@ Type `\q` to exit the PostgreSQL client.
72
71
73
72
Next, set up and run the sample Python Django web app.
74
73
75
-
The sample repository contains the finished data-driven [Django](https://www.djangoproject.com/) polls app from [Writing your first Django app](https://docs.djangoproject.com/en/2.1/intro/tutorial01/) in the Django documentation. You can connect this or another data-driven Python Django web app to a local or cloud PostgreSQL database back end, and deploy the app to Azure App Service.
74
+
The [djangoapp](https://github.com/Azure-Samples/djangoapp)sample repository contains the finished data-driven [Django](https://www.djangoproject.com/) polls app you get from following [Writing your first Django app](https://docs.djangoproject.com/en/2.1/intro/tutorial01/) in the Django documentation. You can connect this, or any other data-driven Python Django web app, to a local or cloud PostgreSQL database back end, and deploy the app to Azure App Service.
76
75
77
76
### Clone the sample app
78
77
79
-
Open a terminal window, and run the following commands to clone the sample app repository and change to the new working directory:
78
+
In a terminal window, run the following commands to clone the sample app repository and change to the new working directory:
In the `venv` environment, run *env.sh* or *env.ps1* to set the environment variables that *azuresite/settings.py* uses for the database connection settings.
99
+
In the `venv` environment, change to your *djangoapp* folder and run *env.sh* or *env.ps1* to set the environment variables *azuresite/settings.py* will use for the database connection settings.
103
100
104
101
```bash
105
102
source ./env.sh
@@ -109,7 +106,7 @@ or
109
106
.\env.ps1
110
107
```
111
108
112
-
In the `venv` environment, install the required packages from *requirements.txt*, run [Django migrations](https://docs.djangoproject.com/en/2.1/topics/migrations/), and [create an admin user](https://docs.djangoproject.com/en/2.1/intro/tutorial02/#creating-an-admin-user):
109
+
Install the required packages from *requirements.txt*, run [Django migrations](https://docs.djangoproject.com/en/2.1/topics/migrations/), and [create an admin user](https://docs.djangoproject.com/en/2.1/intro/tutorial02/#creating-an-admin-user):
Once the admin user is created, run the Django server.
119
+
After you create the admin user, run the Django server.
123
120
124
121
```bash
125
122
python manage.py runserver
126
123
```
127
124
128
-
When the Django web app is fully loaded, you see something similar to the following message:
125
+
When the Django web app is fully loaded, it returns something like the following message:
129
126
130
127
```bash
131
128
Performing system checks...
132
129
133
130
System check identified no issues (0 silenced).
134
-
October 26, 2018 - 10:54:59
131
+
December 13, 2019 - 10:54:59
135
132
Django version 2.1.2, using settings 'azuresite.settings'
136
133
Starting development server at http://127.0.0.1:8000/
137
-
Quit the server with CONTROL-C.
134
+
Quit the server with CTRL-BREAK.
138
135
```
139
136
140
137
Go to *http:\//localhost:8000* in a browser. You should see the message **No polls are available**.
@@ -211,7 +208,7 @@ az postgres server firewall-rule create --resource-group <resourcegroup-name> --
211
208
> [!NOTE]
212
209
> The preceding setting allows network connections from all IP addresses within the Azure network. For production use, try to configure the most restrictive firewall rules possible by [using only the outbound IP addresses your app uses](../overview-inbound-outbound-ips.md?toc=%2fazure%2fapp-service%2fcontainers%2ftoc.json#find-outbound-ips).
213
210
214
-
In the Cloud Shell, run the `firewall-rule-create` command again to allow access from your local computer. Replace *\<your-ip-address>* with [your local IPv4 IP address](https://www.whatsmyip.org/). Replace the *\<postgresql-name>* and *\<resourcegroup-name>* placeholders with your values.
211
+
Run the `firewall-rule-create` command again to allow access from your local computer. Replace *\<your-ip-address>* with [your local IPv4 IP address](https://www.whatsmyip.org/). Replace the *\<postgresql-name>* and *\<resourcegroup-name>* placeholders with your values.
215
212
216
213
```azurecli-interactive
217
214
az postgres server firewall-rule create --resource-group <resourcegroup-name> --server-name <postgresql-name> --start-ip-address=<your-ip-address> --end-ip-address=<your-ip-address> --name AllowLocalClient
@@ -240,7 +237,7 @@ Type `\q` to exit the PostgreSQL client.
240
237
241
238
### Test app connectivity to the Azure Database for PostgreSQL production database
242
239
243
-
In the `venv` environment in your local terminal window, change the database environment variables, which you configure by running *env.sh* or *env.ps1*. Replace*\<postgresql-name>* with your Azure Database for PostgreSQL server name.
240
+
Edit your local *env.sh* or *env.ps1* file to change the environment variables to your cloud PostgreSQL database by replacing*\<postgresql-name>* with your Azure Database for PostgreSQL server name.
In the `venv` environment in your local terminal window, run *env.sh* or *env.ps1* again.
257
+
```bash
258
+
source ./env.sh
259
+
```
260
+
or
261
+
```PowerShell
262
+
.\env.ps1
263
+
```
264
+
259
265
Run Django migration to the Azure database and create an admin user.
260
266
261
267
```bash
@@ -287,7 +293,7 @@ You need to change and add some settings in your *djangoapp/azuresite/settings.p
287
293
288
294
1. Django validates the `HTTP_HOST` header in incoming requests. For your Django web app to work in App Service, you need to add the fully qualified domain name of the app to the allowed hosts.
289
295
290
-
Open*azuresite/settings.py*and change the `ALLOWED_HOSTS` line as follows.
296
+
Edit*azuresite/settings.py*to change the `ALLOWED_HOSTS` line as follows.
For more information about configuring WhiteNoise, see the [WhiteNoise documentation](https://whitenoise.evans.io/en/stable/).
317
322
318
323
> [!IMPORTANT]
319
-
> The database settings section already follows the security best practice of using environment variables. For the complete deployment recommendations, see [Django Documentation: deployment checklist](https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/).
324
+
> The database settings section already follows the security best practice of using environment variables. For complete deployment recommendations, see [Django Documentation: deployment checklist](https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/).
320
325
321
326
Commit your changes into your fork of the repository:
Earlier in the tutorial, you defined environment variables to connect to your PostgreSQL database.
342
347
343
-
In App Service, you set environment variables as _app settings_ by using the [`az webapp config appsettings set`](/cli/azure/webapp/config/appsettings?view=azure-cli-latest#az-webapp-config-appsettings-set) command in Cloud Shell.
348
+
In App Service, you set environment variables as *app settings* by using the [az webapp config appsettings set](/cli/azure/webapp/config/appsettings?view=azure-cli-latest#az-webapp-config-appsettings-set) command in Cloud Shell.
344
349
345
350
The following example specifies the database connection details as app settings.
346
351
@@ -376,21 +381,17 @@ To https://<app-name>.scm.azurewebsites.net/<app-name>.git
376
381
06b6df4..6520eea master -> master
377
382
```
378
383
379
-
The App Service deployment server sees _requirements.txt_ in the repository root and runs Python package management automatically after `git push`.
384
+
The App Service deployment server sees *requirements.txt* in the repository root and runs Python package management automatically after `git push`.
380
385
381
386
### Browse to the Azure app
382
387
383
-
Browse to the deployed app. It takes some time to start because the container needs to be downloaded and run when the app is requested for the first time. If the page times out or displays an error message, wait a few minutes and refresh the page.
384
-
385
-
```bash
386
-
http://<app-name>.azurewebsites.net
387
-
```
388
+
Browse to the deployed app with URL *https:\//\<app-name>.azurewebsites.net*. It takes some time to start because the container needs to be downloaded and run when the app is requested for the first time. If the page times out or displays an error message, wait a few minutes and refresh the page.
388
389
389
390
You should see the poll question that you created earlier.
390
391
391
-
App Service detects a Django project in your repository by looking for a _wsgi.py_in each subdirectory, which is created by `manage.py startproject` by default. When it finds the file, it loads the Django web app. For more information on how App Service loads Python apps, see [Configure built-in Python image](how-to-configure-python.md).
392
+
App Service detects a Django project in your repository by looking for a *wsgi.py* file in each subdirectory, which `manage.py startproject`creates by default. When App Service finds the file, it loads the Django web app. For more information on how App Service loads Python apps, see [Configure built-in Python image](how-to-configure-python.md).
392
393
393
-
Go to `<app-name>.azurewebsites.net` and sign in using same admin user you created. If you like, try creating some more poll questions.
394
+
Go to *https:\//\<app-name>.azurewebsites.net/admin* and sign in using the admin user you created. If you like, create some more poll questions.
394
395
395
396

396
397
@@ -402,35 +403,24 @@ Go to `<app-name>.azurewebsites.net` and sign in using same admin user you creat
402
403
403
404
## Manage your app in the Azure portal
404
405
405
-
Go to the [Azure portal](https://portal.azure.com) to see the app you created.
406
-
407
-
From the left menu, select **App Services**, then select the name of your Azure app.
406
+
In the [Azure portal](https://portal.azure.com) search for and select the app you created.
408
407
409
408

410
409
411
-
By default, the portal shows your app's **Overview** page. This page gives you a view of how your app is doing. Here, you can also perform basic management tasks like browse, stop, start, restart, and delete. The tabs on the left side of the page show the different configuration pages you can open.
410
+
By default, the portal shows your app's **Overview** page. This page gives you a view of how your app is doing. Here, you can also perform basic management tasks like browse, stop, swap, restart, and delete. The tabs on the left side of the page show the different configuration pages you can open.
412
411
413
412

0 commit comments