I have an Azure function witch python that connect a database azure SQL, I’m using the package pyodbc to connect database. On my computer it's working, but when I deploy via vscode, azure does all the python installations based on the requirements and he tries to do the download through website https://github.com/pypa/pip/issues/8368./n , which is out There is another way to access Azure SQL with Python in an Azure Function?? I’m using the above tools Developer in VSCODE in Windows 10 Azure Functions: Linux Type azure function is “HTTP” Local is East 2
My code
Import pyodbc
password = *********
server = 'prd-xx-xxx-xxx-01.database.windows.net'
database = 'prd-xx-xxx-xxx-db-02'
username = 'adm'
driver= '{ODBC Driver 17 for SQL Server}'
conn = pyodbc.connect('DRIVER='+driver+';SERVER='+server+';PORT=1433;DATABASE='+database+';UID='+username+';PWD='+ password)
df = pd.read_sql(select_cidades,conn)
conn.close()
The Python worker comes with an ODBC 17 driver. It's not documented at this time, but you can use it by adding pyodbc to your requirements.txt file in VS Code. See: https://github.com/MicrosoftDocs/azure-docs/issues/54423
The documented way to solve this is to use an environment where you can provide the package. You can create a Docker custom image with the Azure Function runtime and publish in the Azure Cloud (or in an on-premise infrastructure).
https://medium.com/globant/serverless-applications-with-azure-functions-python-and-docker-b594fb90fd4f
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With