2

I am trying to

Create a Azure function in Python on Visual Studio Code to trigger queue.

also i am trying to

Get data from queue and save messages from queue in sql server using python.

Can anyone help?

Sanjiv
  • 980
  • 2
  • 11
  • 29
  • The first question, please config the python environment 3.6, 3.7(func 2.0) or 3.7, 3.8(func 3.0).And install azure function core tools to create. – Cindy Pau Aug 03 '20 at 14:24
  • 1
    For more details, please follow these steps under 'deploy serverless Azure Functions'.:https://learn.microsoft.com/en-us/azure/developer/python/tutorial-vs-code-serverless-python-01 – Cindy Pau Aug 03 '20 at 14:29
  • The second question I am not sure, can you explain about that? – Cindy Pau Aug 03 '20 at 14:43
  • @BowmanZhu 2nd question is like.. I want to trigger azure storage and get the messages from there and stored in sql server db using azure function – Sanjiv Aug 03 '20 at 15:06
  • The sql server db is azure sql db or something else? If you are talking about azure sql ad, then you need to write the code manually in the body of azure function because azure function dont have this kind of binding. – Cindy Pau Aug 03 '20 at 15:09
  • @BowmanZhu forget about sql server. db can be any db. main is how to fetch messages from azure storage using azure function in python – Sanjiv Aug 03 '20 at 15:13
  • 1
    You need to put the part of connection to sql db and others in the body of azure function, that is basiclly as same as common python script. If you have the code works, you can check and put it in the body of azure function. – Cindy Pau Aug 03 '20 at 15:16
  • @BowmanZhu Can you share some document regarding this. Actually i new to this – Sanjiv Aug 03 '20 at 15:18
  • 1
    This should meet your requirements: https://datatofish.com/how-to-connect-python-to-sql-server-using-pyodbc/ It shows you how to connect and how to use the sql statement in python. – Cindy Pau Aug 03 '20 at 15:21
  • @BowmanZhu But how to trigger to azure storage using azure function? before connect to db, i need to connect to azure storage. – Sanjiv Aug 03 '20 at 15:22
  • If you didn't connect to sql db with python before, you can create a simple python script and after it works you can put it in the functions. – Cindy Pau Aug 03 '20 at 15:23
  • What means trigger to azure storage? You want put something to azure storage after function be triggered? I am not sure with your description. No matter input or output about azure storage, you can use binding. – Cindy Pau Aug 03 '20 at 15:24
  • @BowmanZhu I have some messages in queue in azure storage, i want to get those messages and stored in sql db. This is the requirement – Sanjiv Aug 03 '20 at 15:26
  • 1
    OK, but azure function dont have an easy way to input queue message like binding. Please wait, I will give you some simple code. – Cindy Pau Aug 03 '20 at 15:29
  • @BowmanZhu Okay. Thank you :) – Sanjiv Aug 03 '20 at 15:29
  • 1
    This should be more helpful: https://learn.microsoft.com/en-us/azure/storage/queues/storage-quickstart-queues-python It will tells you some basiclly concepts. If you have some problems please let me know. – Cindy Pau Aug 03 '20 at 15:33
  • Can I post an answer to this question? – Cindy Pau Aug 03 '20 at 15:34
  • @BowmanZhu okay.. i will accept that answer. post it – Sanjiv Aug 03 '20 at 15:35

1 Answers1

2

Create a Azure function in Python on Visual Studio Code to trigger queue.

1, Azure functions develop mainly need two things: language environment and azure function core tools.

Total steps:

https://learn.microsoft.com/en-us/azure/developer/python/tutorial-vs-code-serverless-python-01

2, There is no easy way to get message from azure queue storage. This doc will tells you every steps and basiclly concepts:

https://learn.microsoft.com/en-us/azure/storage/queues/storage-quickstart-queues-python

Get data from queue and save messages from queue in sql server using python.

It is just the same with other simple python script, you can follow this:

https://datatofish.com/how-to-connect-python-to-sql-server-using-pyodbc/

The code of getting message from queue and putting message to sql db needs to put to the body of your function.

Cindy Pau
  • 13,085
  • 1
  • 15
  • 27