Stijn Koordijk
Stijn Koordijk

Reputation: 51

How do you trigger an Azure function via HTTP without providing a variable?

How do you trigger an Azure function via HTTP without providing a variable?

Microsoft's documentation example [1] got an example where you have to provide a variable (name) in the URL. How can I remove all code associated with the variable such that it just uses an HTTP connection?

The reason for this is that I want to run my function using Azure Data Factory, but my function does not need an input

[1] https://learn.microsoft.com/en-Us/azure/azure-functions/functions-bindings-http-webhook-trigger?tabs=in-process%2Cfunctionsv2&pivots=programming-language-python

Upvotes: 2

Views: 1426

Answers (1)

Peter Bons
Peter Bons

Reputation: 29880

I am not sure what the actual problem is. Just remove the code that accesses the querystring like this:

import logging
import azure.functions as func

def main(req: func.HttpRequest) -> func.HttpResponse:
    logging.info('Python HTTP trigger function processed a request.')
    
    return func.HttpResponse(f"Hello there, This HTTP triggered function executed successfully.")

and call it using the function url, for example https://xxx.azurewebsites.net/api/HttpTrigger1?code=function_key_here

Upvotes: 2

Related Questions