This is a follow up question to this post.
I have a data warehouse table exposed via xxx.com\data
API endpoint
I have been querying this table using the following code and parsing it into a dataframe as follows;
import requests
import json
import http.client
import pandas as pd
url = "xxx.com\data?q=Active%20%3D1%20and%20LATITUDE%20%3D%20%20%220.000000%22%20and%20LONGITUDE%20%3D%20%220.000000%22&pageSize =300"
payload = {}
headers = {'Authorization': access_token}
response = requests.request("GET", url, headers=headers, data = payload)
j=json.loads(response.text.encode('utf8'))
df = pd.json_normalize(j['DataSet'])
The warehouse table gets periodically updated and I am required to create a webhook to be listened to by the following Azure httptrigger
;
import logging
import os
import json
import pandas as pd
import azure.functions as func
def main(req: func.HttpRequest) -> func.HttpResponse:
logging.info('Python HTTP trigger function processed a request.')
d={
'Date' :['2016-10-30','2016-10-30','2016-11-01','2016-10-30'],
'Time':['09:58:11', '10:05:34', '10:07:57', '11:15:32'],
'Transaction':[2,3,1,1]
}
df=pd.DataFrame(d, columns=['Date','Time','Transaction'])
output = df.to_csv (index_label="idx", encoding = "utf-8")
return func.HttpResponse(output)
When run,the httptrigger successfully listens to the following webhooker sender which I have created and am running locally on my disk.
import logging
import os
import json
import pandas as pd
data={'Lat': '0.000000',
'Long': '0.000000',
'Status': '1', 'Channel URL':"xxx.com\data"}
webhook_url="http://localhost:7071/api/HttpTrigger1"
r=requests.post(webhook_url, headers={'Content-Type':'application/json'}, data =json.dumps(l))
My question is;
- How can I deploy the webhook sender to the cloud as an app so that every time "
xxx.com\data
" is updated withLat==0
,Long=00
andStatus=1
, a message is send to my webhook listener?
The app can either be Azure/Flask/postman or any other python based webhook builder.