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: articles/app-service/containers/tutorial-python-postgresql-app.md
+20-22Lines changed: 20 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,34 +1,33 @@
1
1
---
2
-
title: Python (Django) with PostgreSQL on Linux - Azure App Service | Microsoft Docs
3
-
description: Learn how to run a data-driven Python app in Azure, with connection to a PostgreSQL database. Django is used in the tutorial.
2
+
title: Python (Django) web app with PostgreSQL on Linux - Azure App Service | Microsoft Docs
3
+
description: Learn how to run a data-driven Python (Django) web app in Azure, with connection to a PostgreSQL database.
4
4
services: app-service\web
5
5
documentationcenter: python
6
6
author: cephalin
7
-
manager: jeconnoc
7
+
manager: gwallace
8
8
ms.service: app-service-web
9
9
ms.workload: web
10
10
ms.devlang: python
11
11
ms.topic: tutorial
12
12
ms.date: 03/27/2019
13
13
ms.author: cephalin
14
-
ms.reviewer: beverst
15
14
ms.custom: mvc
16
15
ms.custom: seodec18
17
16
---
18
-
# Build a Python and PostgreSQL app in Azure App Service
17
+
# Build a Python (Django) web app with PostgreSQL in Azure App Service
19
18
20
-
[App Service on Linux](app-service-linux-intro.md) provides a highly scalable, self-patching web hosting service. This tutorial shows how to create a data-driven Python app, using PostgreSQL as the database backend. When you are done, you have a Django application running in App Service on Linux.
19
+
[App Service on Linux](app-service-linux-intro.md) provides a highly scalable, self-patching web hosting service. This tutorial shows how to create a data-driven Python (Django) web app, using PostgreSQL as the database back-end. When you are done, you have a Django web application running in Azure App Service on Linux.
21
20
22
-

21
+

23
22
24
23
In this tutorial, you learn how to:
25
24
26
25
> [!div class="checklist"]
27
26
> * Create a PostgreSQL database in Azure
28
-
> * Connect a Python app to PostgreSQL
29
-
> * Deploy the app to Azure
27
+
> * Connect a Python web app to PostgreSQL
28
+
> * Deploy the Python web app to Azure
30
29
> * View diagnostic logs
31
-
> * Manage the app in the Azure portal
30
+
> * Manage the Python web app in the Azure portal
32
31
33
32
> [!NOTE]
34
33
> Before creating an Azure Database for PostgreSQL, please check [which compute generation is available in your region](https://docs.microsoft.com/azure/postgresql/concepts-pricing-tiers#compute-generations-and-vcores).
This sample repository contains a [Django](https://www.djangoproject.com/) application. It's the same data-driven app you would get by following the [getting started tutorial in the Django documentation](https://docs.djangoproject.com/en/2.1/intro/tutorial01/). This tutorial doesn't teach you Django, but shows you how to take deploy and run a Django app (or another data-driven Python app) to App Service.
90
+
This sample repository contains a [Django](https://www.djangoproject.com/) application. It's the same data-driven app you would get by following the [getting started tutorial in the Django documentation](https://docs.djangoproject.com/en/2.1/intro/tutorial01/). This tutorial doesn't teach you Django, but shows you how to take deploy and run a Django web app (or another data-driven Python app) to Azure App Service.
92
91
93
92
### Configure environment
94
93
@@ -124,7 +123,7 @@ Once the admin user is created, run the Django server.
124
123
python manage.py runserver
125
124
```
126
125
127
-
When the app is fully loaded, you see something similar to the following message:
126
+
When the Django web app is fully loaded, you see something similar to the following message:
128
127
129
128
```bash
130
129
Performing system checks...
@@ -211,7 +210,7 @@ az postgres server firewall-rule create --resource-group myResourceGroup --serve
211
210
212
211
## Connect Python app to production database
213
212
214
-
In this step, you connect your Django sample app to the Azure Database for PostgreSQL server you created.
213
+
In this step, you connect your Django web app to the Azure Database for PostgreSQL server you created.
215
214
216
215
### Create empty database and user access
217
216
@@ -279,11 +278,10 @@ In this step, you deploy the Postgres-connected Python application to Azure App
279
278
280
279
### Configure repository
281
280
282
-
Django validates the `HTTP_HOST` header in incoming requests. For your Django app to work in App Service, you need to add the full-qualified domain name of the app to the allowed hosts. Open _azuresite/settings.py_ and find the `ALLOWED_HOSTS` setting. Change the line to:
281
+
Django validates the `HTTP_HOST` header in incoming requests. For your Django web app to work in App Service, you need to add the full-qualified domain name of the app to the allowed hosts. Open _azuresite/settings.py_ and find the `ALLOWED_HOSTS` setting. Change the line to:
Next, Django doesn't support [serving static files in production](https://docs.djangoproject.com/en/2.1/howto/static-files/deployment/), so you need to enable this manually. For this tutorial, you use [WhiteNoise](https://whitenoise.evans.io/en/stable/). The WhiteNoise package is already included in _requirements.txt_. You just need to configure Django to use it.
You should see the poll question that you created earlier.
383
381
384
-
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 app. For more information on how App Service loads Python apps, see [Configure built-in Python image](how-to-configure-python.md).
382
+
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).
385
383
386
384
Navigate to `<app-name>.azurewebsites.net` and sign in using same admin user you created. If you like, try creating some more poll questions.
387
385
388
386

389
387
390
-
**Congratulations!** You're running a Python app in App Service for Linux.
388
+
**Congratulations!** You're running a Python (Django) web app in Azure App Service for Linux.
391
389
392
390
## Stream diagnostic logs
393
391
@@ -413,10 +411,10 @@ In this tutorial, you learned how to:
413
411
414
412
> [!div class="checklist"]
415
413
> * Create a PostgreSQL database in Azure
416
-
> * Connect a Python app to PostgreSQL
417
-
> * Deploy the app to Azure
414
+
> * Connect a Python web app to PostgreSQL
415
+
> * Deploy the Python web app to Azure
418
416
> * View diagnostic logs
419
-
> * Manage the app in the Azure portal
417
+
> * Manage the Python web app in the Azure portal
420
418
421
419
Advance to the next tutorial to learn how to map a custom DNS name to your app.
422
420
@@ -426,4 +424,4 @@ Advance to the next tutorial to learn how to map a custom DNS name to your app.
0 commit comments