I am using an azure function that has a time trigger and I am trying to communication with a data base to return a list of dictionaries, I am trying to send each dictionary as a string (queue message) to a queue, I was going to do this with an output binder but could not figure out how to, so I am using the azure module. Problem is every message I send goes into a poison queue for some reason, and I cannot figure out why, here is a code snippet of what I have in my Azure function.
import os
import platform
import WorkWithDatabase
#import base64
from azure.storage.queue import QueueService
acc='...ACCOUNT NAME'
key='...KEY'
#Connect to QueueService
queue_service = QueueService(account_name=acc, account_key=key)
#Pull missing data from the database,
#Call a function in another script to do this
missingList=WorkWithDatabase.ListRequests()
for item in missingList:
queue_service.put_message('taskqueue', str(item))
Also Is there a way I can use the database as a resource in an azure function with python??
For using these python packages, such as pyodbc
or pymssql
to connect Azure SQL Database, you need to install a custom version of Python on Azure Function, then to install pip
for the custom verion of Python to install these package as you want.
So the steps as below.
site\\tools
of Kudu via access the url https://<your function name>.scm.azurewebsites.net/DebugConsole
. get-pip.py
file to the path site\\tool
of custom Python, then to install pip
tool via command python get-pip.py
. Scripts/pip.exe install <package-names>
. Then, you can import these packages to write your code in your Azure Function on Azure portal.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.