Skip to content

Commit 8b31e6a

Browse files
committed
Add Tutorial: Python connect to Azure services securely with Key Vault for language parity
1 parent 2af9fef commit 8b31e6a

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

articles/app-service/toc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,8 @@
192192
href: tutorial-connect-msi-key-vault-javascript.md
193193
- name: Use PHP
194194
href: tutorial-connect-msi-key-vault-php.md
195+
- name: Use Python
196+
href: tutorial-connect-msi-key-vault-python.md
195197
- name: Connect by using app identity
196198
items:
197199
- name: Managed identity overview
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
---
2+
title: 'Tutorial: Python connect to Azure services securely with Key Vault'
3+
description: Learn how to secure connectivity to back-end Azure services that don't support managed identity natively from a Python web app
4+
ms.devlang: python
5+
# ms.devlang: python, azurecli
6+
ms.topic: tutorial
7+
ms.date: 08/05/2024
8+
author: cephalin
9+
ms.author: cephalin
10+
11+
ms.reviewer: madsd
12+
ms.custom: devx-track-azurecli, devx-track-python, AppServiceConnectivity
13+
---
14+
15+
# Tutorial: Secure Cognitive Service connection from Python App Service using Key Vault
16+
17+
18+
[!INCLUDE [tutorial-content-above-code](./includes/tutorial-connect-msi-key-vault/introduction.md)]
19+
20+
## Configure Python app
21+
22+
Clone the sample repository locally and deploy the sample application to App Service. Replace *\<app-name>* with a unique name.
23+
24+
```azurecli-interactive
25+
# Clone and prepare sample application
26+
git clone https://github.com/Azure-Samples/app-service-language-detector.git
27+
cd app-service-language-detector/python
28+
zip -r default.zip *.*
29+
30+
# Save app name as variable for convenience
31+
appName=<app-name>
32+
33+
az appservice plan create --resource-group $groupName --name $appName --sku FREE --location $region --is-linux
34+
az webapp create --resource-group $groupName --plan $appName --name $appName --runtime "python:3.11"
35+
az webapp config appsettings set --resource-group $groupName --name $appName --settings SCM_DO_BUILD_DURING_DEPLOYMENT=true
36+
az webapp deploy --resource-group $groupName --name $appName --src-path ./default.zip
37+
```
38+
39+
The preceding commands:
40+
* Create a linux app service plan
41+
* Create a web app for Python 3.11
42+
* Configure the web app to install the python packages on deployment
43+
* Upload the zip file, and install the python packages
44+
45+
## Configure secrets as app settings
46+
47+
[!INCLUDE [tutorial-content-below-code](./includes/tutorial-connect-msi-key-vault/cleanup.md)]

0 commit comments

Comments
 (0)