How to make Http trigger work on this azure function that works fine as timetrigger ?

Nuno Trigo 51 Reputation points

def main(mytimer: func.TimerRequest) -> None:

default_credential= DefaultAzureCredential()  

# Create a Secret Client, so we can grab our Connection String.  
secret_client =SecretClient(  
    vault_url= "*******",  
    credential= default_credential  
# Grab the Blob Connection String, from our Azure Key Vault.  
blob_conn_string = secret_client.get_secret(       
# Connect to the Container.  
container_client = ContainerClient.from_connection_string(      
my_blobs = container_client.list_blobs(name_starts_with="SS")  
table_01222 = "********01222/"  
query_01222 =  {"query":[{"code":"Region","selection":{"filter":"agg:KommSummer","values":["K-0301"]}},{"code":"ContentsCode","selection":{"filter":"item","values":["Fodselsoverskudd4","Nettoinnflytting9"]}}],"response":{"format":"json-stat2"}}  

"#several api requests to several tables"

tables=[table_01222,table_03013,table_03014,table_03723,table_05327, table_07129,table_07221,table_08931,table_09030,  
        table_09031,table_09175,table_09189,table_09786, table_11618,table_11721]  
queries= [query_01222,query_03013,query_03014,query_03723,query_05327, query_07129,query_07221,query_08931,query_09030,  
          query_09031,query_09175,query_09189,query_09786, query_11618,query_11721]  
names=["table_01222","table_03013","table_03014","table_03723","table_05327", "table_07129","table_07221","table_08931","table_09030",  
       "table_09031","table_09175","table_09189","table_09786", "table_11618","table_11721"]  

for i in range(len(tables)):  
    resultat =[i], json = queries[i])  
    dataset =  
    df = dataset.write('dataframe')  
    for name in df.columns:  
       if name == "kvartal":  
            df=df.pivot_table(index=name, columns='statistikkvariabel', values='value')  
       elif name == "år":  
           df=df.pivot_table(index=name, columns='statistikkvariabel', values='value')  
       elif name== "måned":  
           df=df.pivot_table(index=name, columns='statistikkvariabel', values='value')  
    #df.to_csv('SSB - %s opprettet %s - %s.csv'%(names[i],ts.month,ts.year))  
    container_client.upload_blob(name = 'SSB - %s opprettet %s - %s.csv'%(names[i],ts.month,ts.year),  

I want to trigger this using hhtp trigger so I can use this function on Azure Data factory! I am not interested in a response to the trigger, I just want that the trigger starts henting data from an API and deliver that on a blob !

thanks in advance.!

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,353 questions
Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
9,695 questions
0 comments No comments
{count} votes

Accepted answer
  1. MughundhanRaveendran-MSFT 12,436 Reputation points

    Hi @Nuno Trigo ,

    Thanks for reaching out to Q&A.

    Since python functions are dynamically typed, you can use the same code inside the http triggered function template. You can return a simple success response to the ADF pipeline in case the code succeeds without any exceptions.

    Please review the timeout limitation :

    Hope this helps! Feel free to reach out to me if you have any questions or concerns.

0 additional answers

Sort by: Most helpful