Azure Function error on Data Factory , 3608 Error - Call to provided Azure function 'testhttpmohsen' failed with status-'NotFound' and message - 'Invoking Azure function failed with HttpStatusCode - NotFound.'

Mohsen Akhavan 771 Reputation points
2021-03-12T17:43:38.187+00:00

I have an Azure function (HTTP Trigger) and run correctly. When I add this function to Azure Data Factory and run Debug, I received this error.

77285-image.png

my code is:

import logging  
  
import azure.functions as func  
  
  
def main(req: func.HttpRequest) -> func.HttpResponse:  
    logging.info('Python HTTP trigger function processed a request.')  
  
    name = req.params.get('name')  
    if not name:  
        try:  
            req_body = req.get_json()  
        except ValueError:  
            pass  
        else:  
            name = req_body.get('name')  
  
    if name:  
        return func.HttpResponse(f"Hello, {name}. This HTTP triggered function executed successfully.")  
  
    else:  
        return func.HttpResponse(  
             "This HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response.",  
             status_code=200  
        )  
Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,653 questions
Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
10,161 questions
{count} votes

2 answers

Sort by: Most helpful
  1. ellishar 10 Reputation points
    2023-03-09T13:40:20.09+00:00

    Just a note for anyone else encountering this problem after following the quickstart guide for Python V2 Quickstart: Create a function in Azure with Python using Visual Studio Code and then trying to use that demo function in an ADF pipeline:

    The V2 demo code provided includes some decorators above the function def

    app = func.FunctionApp()
    @app.function_name(name="HttpTrigger1")
    @app.route(route="hello", auth_level=func.AuthLevel.ANONYMOUS)
    

    The app route decorator sets the URL of the function to use the specified route name, instead of the function name (default), so when you deploy the function, the URL will be https://your_function_app.azurewebsites.net/api/hello

    When adding an Azure Function activity to an ADF pipeline, you must specify the name used in the route arg (in this case "hello") of app.route() as the function name in order for ADF to correctly locate the function. If you use the name of your function as it appears in Azure (assuming that differs from the route arg), ADF will return the error "Invoking Azure function failed with HttpStatusCode - NotFound."

    1 person found this answer helpful.

  2. MayankBargali-MSFT 70,006 Reputation points
    2021-03-15T06:40:32.123+00:00

    Hi @Mohsen Akhavan

    I have looked into the backend logs and I can see that your function app is in the "Stopped" state. Please start your function app by navigating to your function app. The error is expected if there is no function found with the request URL.

    77619-image.png

    Once you see the status as "Running" please test it and let me know if you are still facing the issue.