Skip to content

Commit 1a39f10

Browse files
author
vmagelo
committed
Make changes to explain secret key.
1 parent 5321bbd commit 1a39f10

5 files changed

+11
-5
lines changed

articles/python/includes/python-web-app-managed-identity/connect-postgres-to-app-azure-portal-2.md

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Create application settings:
1313
* *DBUSER* → Enter *webappuser*, the user you created for the managed identity in the previous article. The sample code constructs the correct Postgres username from `DBUSER` and `DBHOST`, so don't include the *@server* portion.
1414
* *STORAGE_ACCOUNT_NAME* → The name of the storage account, which the sample code combines with *blob.core.windows.net* to create the storage URL endpoint.
1515
* *STORAGE_CONTAINER_NAME* → The name of the container in the storage account, where photos are stored. For example, *photos*.
16+
* *SECRET_KEY* → Enter a secret key for the app. This is used for example to encrypt the session cookie. You can generate a value with `python -c "import secrets; print(secrets.token_hex())"`.
1617

1718
1. Confirm you have five settings with the correct values.
1819

articles/python/includes/python-web-app-managed-identity/connect-postgres-to-app-cli.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,5 @@ az webapp config appsettings set `
3737
* *$DBNAME* → Enter *restaurant*, the name of the application database.
3838
* *$DBUSER* → Enter *webappuser*, the user you created for the managed identity in the previous article. The sample code constructs the correct Postgres username from `DBUSER` and `DBHOST`, so don't include the *@server* portion.
3939
* *$STORAGE_ACCOUNT_NAME* → The name of the storage account, which the sample code combines with *blob.core.windows.net* to create the storage URL endpoint.
40-
* *$STORAGE_CONTAINER_NAME* → The name of the container in the storage account, where photos are stored. For example, *photos*.
40+
* *$STORAGE_CONTAINER_NAME* → The name of the container in the storage account, where photos are stored. For example, *photos*.
41+
* *SECRET_KEY* → Enter a secret key for the app. This is used for example to encrypt the session cookie. You can generate a value with `python -c "import secrets; print(secrets.token_hex())"`.

articles/python/includes/python-web-app-managed-identity/connect-postgres-to-app-visual-studio-code-2.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ Add the following settings:
1111
* *DBNAME* → Enter *restaurant*, the name of the application database.
1212
* *DBUSER* → Enter *webappuser*, the user you created for the managed identity in the previous article. The sample code constructs the correct Postgres username from `DBUSER` and `DBHOST`, so don't include the *@server* portion.
1313
* *STORAGE_ACCOUNT_NAME* → The name of the storage account, which the sample code combines with *blob.core.windows.net* to create the storage URL endpoint.
14-
* *STORAGE_CONTAINER_NAME* → The name of the container in the storage account, where photos are stored. For example, *photos*.
14+
* *STORAGE_CONTAINER_NAME* → The name of the container in the storage account, where photos are stored. For example, *photos*.
15+
* *SECRET_KEY* → Enter a secret key for the app. This is used for example to encrypt the session cookie. You can generate a value with `python -c "import secrets; print(secrets.token_hex())"`.

articles/python/tutorial-python-managed-identity-02.md

+5-2
Original file line numberDiff line numberDiff line change
@@ -125,21 +125,24 @@ Connecting Azure Storage Explorer to Azurite is covered in the article [Use the
125125

126126
If you started with one of the sample apps, copy the *.env.sample* file to *.env*. If you didn't start with one of the sample apps, create an *.env* file and make sure you have the dependencies in the *requirements.txt*. Add other packages as needed such as [django-sslserver](https://pypi.org/project/django-sslserver/) or [python-certifi-win32](https://pypi.org/project/python-certifi-win32/).
127127

128-
The *.env* is only used in local development and should look like the example below. The *.env* file contains info about connecting to your local PostgreSQL and Azurite instances:
128+
The *.env* file is only used in local development and should look like the example below. The *.env* file contains info about connecting to your local PostgreSQL and Azurite instances:
129129

130130
```
131131
# Local PostgreSQL connection info
132132
DBNAME=<local-database name>
133133
DBHOST=<local-database-hostname>
134134
DBUSER=<local-db-user-name>
135135
DBPASS=<local-db-password>
136+
SECRET_KEY=<your-secret-key>
136137
137138
# Emulator storage connection info
138139
STORAGE_URL=https://127.0.0.1:10000/devstoreaccount1
139140
STORAGE_CONTAINER_NAME=photos
140141
```
141142

142-
The sample app uses the [python-dotenv](https://pypi.org/project/python-dotenv/) to read environment variables from the *.env* file.
143+
A `SECRET_KEY` key you can use for this tutorial can be generated with the following Python code: `python -c "import secrets; print(secrets.token_hex())"`.
144+
145+
The sample app uses the [python-dotenv](https://pypi.org/project/python-dotenv/) to read environment variables from the *.env* file.
143146

144147
Next, create the `restaurant` and `review` database tables:
145148

articles/python/tutorial-python-managed-identity-06.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ This article is part of a tutorial about deploying a Python app to Azure App Ser
1717

1818
With the web app, storage account, and PostgreSQL database resources created, the next step is to tell the web app how to connect to the Azure Storage account and Azure Database for PostgreSQL service.
1919

20-
The Python sample code expects environment variables named `DBHOST`, `DBNAME`, `DBUSER`, `STORAGE_ACCOUNT_NAME`, and `STORAGE_CONTAINER_NAME` to connect to the storage and database resources. You don't specify an access key for storage or a password for the database because authentication is handled by managed identity.
20+
The Python sample code expects environment variables named `DBHOST`, `DBNAME`, `DBUSER`, `STORAGE_ACCOUNT_NAME`, `STORAGE_CONTAINER_NAME`, and `SECRET_KEY` to connect to the storage and database resources. You don't specify an access key for storage or a password for the database because authentication is handled by managed identity.
2121

2222
### [Azure portal](#tab/azure-portal)
2323

0 commit comments

Comments
 (0)