Skip to content

Commit 039e8e4

Browse files
Merge pull request #283653 from JimacoMS4/add-app-service-python-cog-svc-tutorial
Add Tutorial: Python connect to Azure services securely with Key Vaul…
2 parents 3fd0225 + 63544ec commit 039e8e4

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/23/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+
[!INCLUDE [tutorial-content-above-code](./includes/tutorial-connect-msi-key-vault/introduction.md)]
18+
19+
## Configure Python app
20+
21+
Clone the sample repository locally and deploy the sample application to App Service. Replace *\<app-name>* with a unique name.
22+
23+
```azurecli-interactive
24+
# Clone and prepare sample application
25+
git clone https://github.com/Azure-Samples/app-service-language-detector.git
26+
cd app-service-language-detector/python
27+
zip -r default.zip .
28+
29+
# Save app name as variable for convenience
30+
appName=<app-name>
31+
32+
az appservice plan create --resource-group $groupName --name $appName --sku FREE --location $region --is-linux
33+
az webapp create --resource-group $groupName --plan $appName --name $appName --runtime "python:3.11"
34+
az webapp config appsettings set --resource-group $groupName --name $appName --settings SCM_DO_BUILD_DURING_DEPLOYMENT=true
35+
az webapp deploy --resource-group $groupName --name $appName --src-path ./default.zip
36+
```
37+
38+
The preceding commands:
39+
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)