Running Python Script From Azure Webjob
Solution 1:
I tried to realize your needs with Python in WebJob and successfully make it works.
Here is my steps and sample code. My local environment is Python 3.7 on Windows 10.
Create a Python virtual environment and install
python-telegram-botpackage via commands as below.$ mkdir telegram-webjob$ virtualenv telegram-webjob$ cd telegram-webjob$ Scripts\active$ pip install python-telegram-bot$ pip freezeI changed your code as my sample code, then run it works fine on local, as below.
import telegram from datetime import datetime as dt my_token = '<my token>' bot = telegram.Bot(token = my_token) chat_id = '<chat id>' message = f"Hello at {dt.now()}" bot.sendMessage(chat_id=chat_id, text=message)I created a new directoy named
webjoband copy mytrading.pyfile and all directories with their files into it, as below.Write the startup bat script named
run.bat, the code as below.D:\home\python364x86\python.exe trading.pyThe
D:\home\python364x86\python.exepath is thepython364x86site extension installed path as the figure below.Then, I packaged the all directories and files in the
webjobdirectory as a zip file, as below.I uploaded it to Azure WebApp as a webjob, as the figure below, and start it.
Finally, it works fine for me and I can see the message interval 10 sec displayed in my telegram client.









Post a Comment for "Running Python Script From Azure Webjob"