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
Create an *.env* file as shown below using the *.env.sample* file 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 for your local PostgreSQL instance. The `FLASK_DEBUG` environment variable is optional and used to enable debug mode in Flask.
56
+
57
+
Create an *.env* file as shown below using the *.env.sample* file 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 for your local PostgreSQL instance.
50
58
51
59
```
52
-
FLASK_DEBUG=True
53
60
DBNAME=<database name>
54
61
DBHOST=<database-hostname>
55
62
DBUSER=<db-user-name>
@@ -117,7 +124,7 @@ Sign in to the [Azure portal](https://portal.azure.com/) and follow these steps
117
124
1. *Resource Group*→ Select **Create new** and use a name of **msdocs-python-postgres-tutorial**.
118
125
1. *Region*→ Any Azure region near you.
119
126
1. *Name*→**msdocs-python-postgres-XYZ** where *XYZ* is any three random characters. This name must be unique across Azure.
120
-
1. *Runtime stack*→**Python 3.9**.
127
+
1. *Runtime stack*→**Python 3.10**.
121
128
1. *Database*→**PostgreSQL - Flexible Server** is selected by default as the database engine. The server name and database name is also set by default to appropriate values.
122
129
1. *Hosting plan*→**Basic**. When you're ready, you can [scale up](manage-scale-up.md) to a production pricing tier later.
123
130
1. Select **Review + create**.
@@ -158,8 +165,10 @@ The creation wizard generated the connectivity variables for you already as [app
158
165
:::row-end:::
159
166
:::row:::
160
167
:::column span="2":::
161
-
**Step 2.** In the **Application settings** tab of the **Configuration** page, verify that `DBNAME`, `DBHOST`, `DBUSER`, and `DBPASS` are present. They'll be injected into the runtime environment as environment variables.
162
-
App settings are a good way to keep connection secrets out of your code repository.
168
+
**Step 2.** In the **Application settings** tab of the **Configuration** page, verify that `AZURE_POSTGRESQL_CONNECTIONSTRING` is present. That will be injected into the runtime environment as an environment variable.
169
+
App settings are one way to keep connection secrets out of your code repository.
170
+
When you're ready to move your secrets to a more secure location,
171
+
here's an [article on storing in Azure Key Vault](/azure/key-vault/certificates/quick-create-python).
163
172
:::column-end:::
164
173
:::column:::
165
174
:::image type="content" source="./media/tutorial-python-postgresql-app/azure-portal-get-connection-string-2.png" alt-text="A screenshot showing how to see the autogenerated connection string." lightbox="./media/tutorial-python-postgresql-app/azure-portal-get-connection-string-2.png":::
@@ -391,7 +400,7 @@ Having issues? [Let us know](https://aka.ms/DjangoCLITutorialHelp).
391
400
:::row:::
392
401
:::column span="2":::
393
402
**Step 2.** Add a few restaurants to the list.
394
-
Congratulations, you're running a secure data-driven Flask app in Azure App Service, with connectivity to Azure Database for PostgreSQL.
403
+
Congratulations, you're running a web app in Azure App Service, with secure connectivity to Azure Database for PostgreSQL.
395
404
:::column-end:::
396
405
:::column:::
397
406
:::image type="content" source="./media/tutorial-python-postgresql-app/azure-portal-browse-app-2.png" alt-text="A screenshot of the Flask web app with PostgreSQL running in Azure showing restaurants and restaurant reviews." lightbox="./media/tutorial-python-postgresql-app/azure-portal-browse-app-2.png":::
@@ -406,11 +415,15 @@ Azure App Service captures all messages output to the console to help you diagno
For more robust logging, consider using Django's [built-in logger](https://docs.djangoproject.com/en/4.1/topics/logging/).
414
427
415
428
-----
416
429
@@ -528,11 +541,11 @@ For more information, see [Production settings for Django apps](configure-langua
528
541
529
542
#### I can't connect to the SSH session
530
543
531
-
If you can't connect to the SSH session, then the app itself has failed to start. Check the [diagnostic logs](#6-stream-diagnostic-logs) for details. For example, if you see an error like `KeyError: 'DBNAME'`, it may mean that the environment variable is missing (you may have removed the app setting).
544
+
If you can't connect to the SSH session, then the app itself has failed to start. Check the [diagnostic logs](#6-stream-diagnostic-logs) for details. For example, if you see an error like `KeyError: 'AZURE_POSTGRESQL_CONNECTIONSTRING'`, it may mean that the environment variable is missing (you may have removed the app setting).
532
545
533
546
#### I get an error when running database migrations
534
547
535
-
If you encounter any errors related to connecting to the database, check if the app settings (`DBHOST`, `DBNAME`, `DBUSER`, and `DBPASS`) have been changed. Without those settings, the migrate command can't communicate with the database.
548
+
If you encounter any errors related to connecting to the database, check if the app settings (`AZURE_POSTGRESQL_CONNECTIONSTRING`) have been changed. Without that connection string, the migrate command can't communicate with the database.
0 commit comments