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/tutorial-python-postgresql-app-django.md
+20-19Lines changed: 20 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -261,7 +261,7 @@ The creation wizard generated the connectivity variables for you already as [app
261
261
**Step 7: Configure the Redis connector to use Key Vault secrets**
262
262
1. In the Service Connectors page, select the checkbox next to the Cache for Redis connector, then select **Edit**.
263
263
1. Select the **Authentication** tab.
264
-
1. Select **Store Secret in Key Vault**.
264
+
1. Select **Store Secret in Key Vault**.
265
265
1. Under **Key Vault Connection**, select the key vault you created.
266
266
1. Select **Next: Networking**.
267
267
1. Select **Configure firewall rules to enable access to target service**. The app creation wizard already secured the SQL database with a private endpoint.
@@ -359,7 +359,7 @@ In this step, you'll configure GitHub deployment using GitHub Actions. It's just
359
359
GitHub Copilot doesn't give you the same response every time, and it's not always correct. You might need to ask more questions to fine-tune its response. For tips, see [What can I do with GitHub Copilot in my codespace?](#what-can-i-do-with-github-copilot-in-my-codespace).
360
360
:::column-end:::
361
361
:::column:::
362
-
:::image type="content" source="media/tutorial-python-postgresql-app-flask/github-copilot-1.png" alt-text="A screenshot showing how to ask a question in a new GitHub Copilot chat session." lightbox="media/tutorial-python-postgresql-app-django/github-flask-1.png":::
362
+
:::image type="content" source="media/tutorial-python-postgresql-app-flask/github-copilot-1.png" alt-text="A screenshot showing how to ask a question in a new GitHub Copilot chat session." lightbox="media/tutorial-python-postgresql-app-django/github-copilot-1.png":::
363
363
:::column-end:::
364
364
:::row-end:::
365
365
:::row:::
@@ -409,7 +409,7 @@ Having issues? Check the [Troubleshooting guide](configure-language-python.md#tr
409
409
410
410
## 4. Generate database schema
411
411
412
-
With the PostgreSQL database protected by the virtual network, the easiest way to run [Django database migrations](https://docs.djangoproject.com/en/4.1/topics/migrations/) is in an SSH session with the App Service container.
412
+
With the PostgreSQL database protected by the virtual network, the easiest way to run [Django database migrations](https://docs.djangoproject.com/en/4.1/topics/migrations/) is in an SSH session with the Linux container in App Service.
413
413
414
414
:::row:::
415
415
:::column span="2":::
@@ -423,7 +423,7 @@ With the PostgreSQL database protected by the virtual network, the easiest way t
423
423
:::row-end:::
424
424
:::row:::
425
425
:::column span="2":::
426
-
**Step 2:** In the SSH terminal, run `python manage.py migrate`. If it succeeds, App Service is [connecting successfully to the database](#i-get-an-error-when-running-database-migrations).
426
+
**Step 2:** In the SSH session, run `python manage.py migrate`. If it succeeds, App Service is [connecting successfully to the database](#i-get-an-error-when-running-database-migrations).
427
427
:::column-end:::
428
428
:::column:::
429
429
:::image type="content" source="./media/tutorial-python-postgresql-app-django/azure-portal-generate-db-schema-django-2.png" alt-text="A screenshot showing the commands to run in the SSH shell and their output (Django)." lightbox="./media/tutorial-python-postgresql-app-django/azure-portal-generate-db-schema-django-2.png":::
@@ -577,17 +577,17 @@ Having issues? Check the [Troubleshooting section](#troubleshooting).
577
577
578
578
The AZD template you use generated the connectivity variables for you already as [app settings](configure-common.md#configure-app-settings) and outputs the them to the terminal for your convenience. App settings are one way to keep connection secrets out of your code repository.
579
579
580
-
1. In the AZD output, find the app settings and find the settings `AZURE_POSTGRESQL_USER`, `AZURE_POSTGRESQL_PASSWORD`, `AZURE_POSTGRESQL_HOST`, `AZURE_POSTGRESQL_NAME`, and `AZURE_REDIS_CONNECTIONSTRING`. To keep secrets safe, only the setting names are displayed. They look like this in the azd output:
580
+
1. In the AZD output, find the settings `AZURE_POSTGRESQL_USER`, `AZURE_POSTGRESQL_PASSWORD`, `AZURE_POSTGRESQL_HOST`, `AZURE_POSTGRESQL_NAME`, and `AZURE_REDIS_CONNECTIONSTRING`. To keep secrets safe, only the setting names are displayed. They look like this in the AZD output:
581
581
582
582
<pre>
583
-
App Service app has the following connection settings:
584
-
- AZURE_POSTGRESQL_NAME
585
-
- AZURE_POSTGRESQL_HOST
586
-
- AZURE_POSTGRESQL_USER
587
-
- AZURE_POSTGRESQL_PASSWORD
588
-
- AZURE_REDIS_CONNECTIONSTRING
589
-
- AZURE_KEYVAULT_RESOURCEENDPOINT
590
-
- AZURE_KEYVAULT_SCOPE
583
+
App Service app has the following connection settings:
584
+
- AZURE_POSTGRESQL_NAME
585
+
- AZURE_POSTGRESQL_HOST
586
+
- AZURE_POSTGRESQL_USER
587
+
- AZURE_POSTGRESQL_PASSWORD
588
+
- AZURE_REDIS_CONNECTIONSTRING
589
+
- AZURE_KEYVAULT_RESOURCEENDPOINT
590
+
- AZURE_KEYVAULT_SCOPE
591
591
</pre>
592
592
593
593
1. For your convenience, the AZD template shows you the direct link to the app's app settings page. Find the link and open it in a new browser tab.
@@ -616,7 +616,7 @@ Having issues? Check the [Troubleshooting section](#troubleshooting).
616
616
617
617
# [Without GitHub Copilot](#tab/nocopilot)
618
618
619
-
1. You need to use the four app settings for connectivity in App service. Open *azureproject/production.py*, uncomment the following lines (lines 3-8), and save the file:
619
+
1. You need to use the five app settings for connectivity in App service. Open *azureproject/production.py*, uncomment the following lines (lines 29-48), and save the file:
@@ -637,6 +637,7 @@ Having issues? Check the [Troubleshooting section](#troubleshooting).
637
637
}
638
638
}
639
639
```
640
+
640
641
Your application code is now configured to connect to the PostgreSQL database and Redis cache in Azure.
641
642
642
643
-----
@@ -648,23 +649,23 @@ Having issues? Check the [Troubleshooting section](#troubleshooting).
648
649
```
649
650
650
651
> [!NOTE]
651
-
> If you run `azd up`, it combines `azd package`, `azd provision`, and `azd deploy`. The reason you didn't do it at the beginning was because you didn't have the PostgreSQL connection settings for to modify your code with yet. If you ran `azd up` then, the deploy stage would stall because the Gunicorn server wouldn't be able to start the app without valid connection settings.
652
+
> If you run `azd up`, it combines `azd package`, `azd provision`, and `azd deploy`. The reason you didn't do it at the beginning was because you didn't have the PostgreSQL connection settings to modify your code with yet. If you ran `azd up` then, the deploy stage would stall because the Gunicorn server wouldn't be able to start the app without valid connection settings. But in general, you can rerun these commands when you make changes to your AZD template or to your code.
652
653
653
654
-----
654
655
655
656
Having issues? Check the [Troubleshooting section](#troubleshooting).
656
657
657
658
## 5. Generate database schema
658
659
659
-
With the PostgreSQL database protected by the virtual network, the easiest way to run Django database migrations is in an SSH session with the App Service container.
660
+
With the PostgreSQL database protected by the virtual network, the easiest way to run Django database migrations is in an SSH session with the Linux container inApp Service.
660
661
661
-
1. In the azd output, find the URL forthe SSH session and navigate to itin the browser. It looks like this in the output:
662
+
1. In the AZD output, find the URL forthe SSH session and navigate to itin the browser. It looks like this in the output:
662
663
663
664
<pre>
664
665
Open SSH session to App Service container at: https://<app-name>.scm.azurewebsites.net/webssh/host
665
666
</pre>
666
667
667
-
1. In the SSH terminal, run `python manage.py migrate`. If it succeeds, App Service is [connecting successfully to the database](#i-get-an-error-when-running-database-migrations).
668
+
1. In the SSH session, run `python manage.py migrate`. If it succeeds, App Service is [connecting successfully to the database](#i-get-an-error-when-running-database-migrations).
668
669
669
670
:::image type="content" source="./media/tutorial-python-postgresql-app-django/azure-portal-generate-db-schema-django-2.png" alt-text="A screenshot showing the commands to run in the SSH shell and their output (Django)." lightbox="./media/tutorial-python-postgresql-app-django/azure-portal-generate-db-schema-django-2.png":::
670
671
@@ -767,7 +768,7 @@ Pricing for the created resources is as follows:
767
768
768
769
#### How do I connect to the PostgreSQL server that's secured behind the virtual network with other tools?
769
770
770
-
- For basic access from a command-line tool, you can run `psql` from the app's SSH terminal.
771
+
- For basic access from a command-line tool, you can run `psql` from the app's SSH session.
771
772
- To connect from a desktop tool, your machine must be within the virtual network. For example, it could be an Azure VM that's connected to one of the subnets, or a machine in an on-premises network that has a [site-to-site VPN](../vpn-gateway/vpn-gateway-about-vpngateways.md) connection with the Azure virtual network.
772
773
- You can also [integrate Azure Cloud Shell](../cloud-shell/private-vnet.md) with the virtual network.
Copy file name to clipboardExpand all lines: articles/app-service/tutorial-python-postgresql-app-flask.md
+15-15Lines changed: 15 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -378,7 +378,7 @@ Having issues? Check the [Troubleshooting guide](configure-language-python.md#tr
378
378
379
379
## 4. Generate database schema
380
380
381
-
With the PostgreSQL database protected by the virtual network, the easiest way to run [Flask database migrations](https://flask-migrate.readthedocs.io/en/latest/) is in an SSH session with the App Service container.
381
+
With the PostgreSQL database protected by the virtual network, the easiest way to run [Flask database migrations](https://flask-migrate.readthedocs.io/en/latest/) is in an SSH session with the Linux container in App Service.
382
382
383
383
:::row:::
384
384
:::column span="2":::
@@ -392,7 +392,7 @@ With the PostgreSQL database protected by the virtual network, the easiest way t
392
392
:::row-end:::
393
393
:::row:::
394
394
:::column span="2":::
395
-
**Step 2:** In the SSH terminal, run `flask db upgrade`. If it succeeds, App Service is [connecting successfully to the database](#i-get-an-error-when-running-database-migrations).
395
+
**Step 2:** In the SSH session, run `flask db upgrade`. If it succeeds, App Service is [connecting successfully to the database](#i-get-an-error-when-running-database-migrations).
396
396
:::column-end:::
397
397
:::column:::
398
398
:::image type="content" source="./media/tutorial-python-postgresql-app-flask/azure-portal-generate-db-schema-flask-2.png" alt-text="A screenshot showing the commands to run in the SSH shell and their output." lightbox="./media/tutorial-python-postgresql-app-flask/azure-portal-generate-db-schema-flask-2.png":::
@@ -546,17 +546,17 @@ Having issues? Check the [Troubleshooting section](#troubleshooting).
546
546
547
547
The AZD template you use generated the connectivity variables for you already as [app settings](configure-common.md#configure-app-settings) and outputs the them to the terminal for your convenience. App settings are one way to keep connection secrets out of your code repository.
548
548
549
-
1. In the AZD output, find the app settings and find the settings `AZURE_POSTGRESQL_USER`, `AZURE_POSTGRESQL_PASSWORD`, `AZURE_POSTGRESQL_HOST`, and `AZURE_POSTGRESQL_NAME`. To keep secrets safe, only the setting names are displayed. They look like this in the azd output:
549
+
1. In the AZD output, find the app settings and find the settings `AZURE_POSTGRESQL_USER`, `AZURE_POSTGRESQL_PASSWORD`, `AZURE_POSTGRESQL_HOST`, and `AZURE_POSTGRESQL_NAME`. To keep secrets safe, only the setting names are displayed. They look like this in the AZD output:
550
550
551
551
<pre>
552
-
App Service app has the following connection settings:
553
-
- AZURE_POSTGRESQL_NAME
554
-
- AZURE_POSTGRESQL_HOST
555
-
- AZURE_POSTGRESQL_USER
556
-
- AZURE_POSTGRESQL_PASSWORD
557
-
- AZURE_REDIS_CONNECTIONSTRING
558
-
- AZURE_KEYVAULT_RESOURCEENDPOINT
559
-
- AZURE_KEYVAULT_SCOPE
552
+
App Service app has the following connection settings:
553
+
- AZURE_POSTGRESQL_NAME
554
+
- AZURE_POSTGRESQL_HOST
555
+
- AZURE_POSTGRESQL_USER
556
+
- AZURE_POSTGRESQL_PASSWORD
557
+
- AZURE_REDIS_CONNECTIONSTRING
558
+
- AZURE_KEYVAULT_RESOURCEENDPOINT
559
+
- AZURE_KEYVAULT_SCOPE
560
560
</pre>
561
561
562
562
1. For your convenience, the AZD template shows you the direct link to the app's app settings page. Find the link and open it in a new browser tab.
@@ -613,16 +613,16 @@ Having issues? Check the [Troubleshooting section](#troubleshooting).
613
613
614
614
## 5. Generate database schema
615
615
616
-
With the PostgreSQL database protected by the virtual network, the easiest way to run [Flask database migrations](https://flask-migrate.readthedocs.io/en/latest/) is in an SSH session with the App Service container.
616
+
With the PostgreSQL database protected by the virtual network, the easiest way to run [Flask database migrations](https://flask-migrate.readthedocs.io/en/latest/) is in an SSH session with the Linux container inApp Service.
617
617
618
618
619
-
1. In the azd output, find the URL forthe SSH session and navigate to itin the browser. It looks like this in the output:
619
+
1. In the AZD output, find the URL forthe SSH session and navigate to itin the browser. It looks like this in the output:
620
620
621
621
<pre>
622
622
Open SSH session to App Service container at: https://<app-name>.scm.azurewebsites.net/webssh/host
623
623
</pre>
624
624
625
-
1. In the SSH terminal, run `flask db upgrade`. If it succeeds, App Service is [connecting successfully to the database](#i-get-an-error-when-running-database-migrations).
625
+
1. In the SSH session, run `flask db upgrade`. If it succeeds, App Service is [connecting successfully to the database](#i-get-an-error-when-running-database-migrations).
626
626
627
627
:::image type="content" source="./media/tutorial-python-postgresql-app-flask/azure-portal-generate-db-schema-flask-2.png" alt-text="A screenshot showing the commands to run in the SSH shell and their output." lightbox="./media/tutorial-python-postgresql-app-flask/azure-portal-generate-db-schema-flask-2.png":::
628
628
@@ -707,7 +707,7 @@ Pricing for the created resources is as follows:
707
707
708
708
#### How do I connect to the PostgreSQL server that's secured behind the virtual network with other tools?
709
709
710
-
- For basic access from a command-line tool, you can run `psql` from the app's SSH terminal.
710
+
- For basic access from a command-line tool, you can run `psql` from the app's SSH session.
711
711
- To connect from a desktop tool, your machine must be within the virtual network. For example, it could be an Azure VM that's connected to one of the subnets, or a machine in an on-premises network that has a [site-to-site VPN](../vpn-gateway/vpn-gateway-about-vpngateways.md) connection with the Azure virtual network.
712
712
- You can also [integrate Azure Cloud Shell](../cloud-shell/private-vnet.md) with the virtual network.
0 commit comments