Skip to content

Commit f9963de

Browse files
committed
App Service - PY tutorial - secret leak fix
1 parent e440a33 commit f9963de

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed
25 KB
Loading
12.2 KB
Loading

articles/app-service/tutorial-python-postgresql-app.md

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ Sign in to the [Azure portal](https://portal.azure.com/) and follow these steps
154154

155155
## 2. Verify connection settings
156156

157-
The creation wizard generated the connectivity variables for you already as [app settings](configure-common.md#configure-app-settings).
157+
The creation wizard generated the connectivity variables for you already as [app settings](configure-common.md#configure-app-settings). App settings are one way to keep connection secrets out of your code repository. When you're ready to move your secrets to a more secure location, here's an [article on storing in Azure Key Vault](../key-vault/certificates/quick-create-python.md).
158158

159159
:::row:::
160160
:::column span="2":::
@@ -167,14 +167,33 @@ The creation wizard generated the connectivity variables for you already as [app
167167
:::row:::
168168
:::column span="2":::
169169
**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.
170-
App settings are one way to keep connection secrets out of your code repository.
171-
When you're ready to move your secrets to a more secure location,
172-
here's an [article on storing in Azure Key Vault](../key-vault/certificates/quick-create-python.md).
173170
:::column-end:::
174171
:::column:::
175172
:::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":::
176173
:::column-end:::
174+
:::row:::
175+
:::column span="2":::
176+
**Step 3.** In a terminal or command prompt, run the following Python script to generate a unique secret: `python -c 'import secrets; print(secrets.token_hex())'`. Copy the output value to use in the next step.
177+
:::column-end:::
178+
:::column:::
179+
:::column-end:::
177180
:::row-end:::
181+
:::row:::
182+
:::column span="2":::
183+
**Step 4.** In the **Application settings** tab of the **Configuration** page, select **New application setting**. Name the setting `SECRET_KEY`. Paste the value from the previous value. Select **OK**.
184+
:::column-end:::
185+
:::column:::
186+
:::image type="content" source="./media/tutorial-python-postgresql-app/azure-portal-app-service-app-setting.png" alt-text="A screenshot showing how to set the SECRET_KEY app setting in the Azure portal." lightbox="./media/tutorial-python-postgresql-app/azure-portal-app-service-app-setting.png":::
187+
:::column-end:::
188+
:::row:::
189+
:::column span="2":::
190+
**Step 5.** Select **Save**.
191+
:::column-end:::
192+
:::column:::
193+
:::image type="content" source="./media/tutorial-python-postgresql-app/azure-portal-app-service-app-setting-save.png" alt-text="A screenshot showing how to save the SECRET_KEY app setting in the Azure portal." lightbox="./media/tutorial-python-postgresql-app/azure-portal-app-service-app-setting-save.png":::
194+
:::column-end:::
195+
:::row-end:::
196+
178197

179198
Having issues? Check the [Troubleshooting guide](configure-language-python.md#troubleshooting).
180199

0 commit comments

Comments
 (0)