Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Visual Studio Code Default Python V2 http trigger function does not work with Logic App #1468

Open
matteogazzadi opened this issue Apr 3, 2024 · 4 comments
Assignees
Labels

Comments

@matteogazzadi
Copy link

matteogazzadi commented Apr 3, 2024

I created new python V2 function Http Trigger using Visual Studio Code.
I have not touched the auto generated code, just deployed it.

Then from Azure Logic App, i tried to add the function in my workflow but got constantly the error: "Cannot be called from a logic app. It must not have a custom route."

Doing the same for a C# one does indeed work.

I tried also chaning the @app.route(route="test_http") to @app.route(route="req") and @app.route(methods=["POST"]) but the error on Logic App is persisting and actually did not find a way to overcome this, neither any kind of documentation about this.

Here the function code:

import azure.functions as func
import logging

app = func.FunctionApp(http_auth_level=func.AuthLevel.FUNCTION)

@app.route(route="test_http")
def test_http(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
        )`
@matteogazzadi matteogazzadi changed the title Visual Sutdio Code Default Python V2 http trigger function does not work with Logic App Visual Studio Code Default Python V2 http trigger function does not work with Logic App Apr 3, 2024
@bhagyshricompany bhagyshricompany self-assigned this Apr 8, 2024
@bhagyshricompany
Copy link

Thanks for reporting we are checking in to this and update .

@bhagyshricompany bhagyshricompany transferred this issue from Azure/Azure-Functions Apr 8, 2024
@nveenstra
Copy link

nveenstra commented May 8, 2024

I managed to get it working in a logic app by leaving the route empty:

@app.function_name(name="HttpTrigger")
@app.route(route="")

def main(req: func.HttpRequest) -> func.HttpResponse:

@nakashimagif
Copy link

I managed to get it working in a logic app by leaving the route empty:

@app.function_name(name="HttpTrigger")
@app.route(route="")

def main(req: func.HttpRequest) -> func.HttpResponse:

nveenstra, Thank you! This works for my case.

@suleman-dev71
Copy link

suleman-dev71 commented Oct 2, 2024

I'm facing the same issue, This is failing:

import azure.functions as func
import logging

app = func.FunctionApp()

@app.function_
@app.route()  # No custom route
def http_trigger1(req: func.HttpRequest) -> func.HttpResponse:
    logging.info('HTTP trigger received a request.')
    name = req.params.get('name')
    if not name:
        return func.HttpResponse("Pass a name", status_code=400)
    return func.HttpResponse(f"Hello, {name}. Function executed successfully.")

This doesn't work as well:
@app.route(route="/")
@app.route(route=None)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants