Рет қаралды 3,093
Learn how to securely retrieve secrets from Azure Key Vault and fetch results from an Azure SQL database using the pyodbc library.
In this hands-on lab, you will build a Python based Azure Function (v2). It will retrieve secrets from Azure Keyvault and use them to connect and retrieve results from Azure SQL database. If you want to follow along, you will need an Azure Subscription and setup the prerequisites below:
Prerequisites
=================
Function App Setup
github.com/RussMaxwell/AzurePython/blob/main/Labs/azfunc1/functionappsetup.md
SQL Setup
github.com/RussMaxwell/AzurePython/blob/main/Labs/azfunc1/sqlsetup.md
Keyvault Setup
github.com/RussMaxwell/AzurePython/blob/main/Labs/azfunc1/keyvaultsetup.md
Local Machine Setup
github.com/RussMaxwell/AzurePython/blob/main/Labs/azfunc1/localmachinesetup.md
Source Code - Complete
====================
github.com/RussMaxwell/AzurePython/blob/main/Labs/azfunc1/src/function_app.py
Sample SQL Query to retrieve roles for a user named: funcusr
====================================================
SELECT r.name AS role_name
FROM sys.database_role_members m
JOIN sys.database_principals u ON u.principal_id = m.member_principal_id
JOIN sys.database_principals r ON r.principal_id = m.role_principal_id
WHERE u.name = 'funcusr';
Hands on Lab 2 is now available!
kzfaq.info/get/bejne/pb6TmMh019fLknU.html
5/19/24 - Hands on Lab 3 is now available!
kzfaq.info/get/bejne/a5efqpSer9CWh5s.html
6/19/24 - Hands on Lab4 is now available!
kzfaq.info/get/bejne/mM5kl8J6tN7Llac.html
Timecodes
0:00 - Intro and Setup
2:00 - Validate the Setup
4:27 - Local Machine Setup
5:31 - Create Azure (V2) Function
9:38 - Test vanilla AZ Function runs locally
11:54 - Write code and discuss
28:52 - Run function app locally
32:05 - Deploy solution to Azure Function App