I'm very new to Azure and was able get as far as generating the following init.py file:
import datetime
import logging
import azure.functions as func
def main(mytimer: func.TimerRequest) -> None:
utc_timestamp = datetime.datetime.utcnow().replace(
tzinfo=datetime.timezone.utc).isoformat()
HubspotIngest() #is this where my function goes? Send help pls.
if mytimer.past_due:
logging.info('The timer is past due!')
logging.info('Python timer trigger function ran at %s', utc_timestamp)
Along with the associated function.json:
{
"scriptFile": "__init__.py",
"bindings": [
{
"name": "mytimer",
"type": "timerTrigger",
"direction": "in",
"schedule": "0 0 0 * * *"
}
]
}
but don't know where to input my code so Azure knows what to run when the timer triggers:
from numpy import dtype
import pandas as pd
import requests
import datetime
def HubspotIngest():
df = pd.DataFrame()
print(9)
api_client = HubSpot(api_key= key)
x = requests.get('link')
data = x.json()
for i in range(0, len(data['objects'])):
Id = data['objects'][i]['id']
sent = data['objects'][i]['publishDate']
From = data['objects'][i]['fromName']
subject = data['objects'][i]['subject']
analytics.track('Newsletter', {'datasource': 'hubspot', 'timestamp': datetime.datetime.now(),'id': Id, 'sent':sent, 'from': From, 'subject': subject})
df2 = {'datasource': 'hubspot', 'id': Id, 'sent':sent, 'from': From, 'subject': subject}
df = dfappend(df1, ignore_index = True)
Thank you for your time!