Subject: 404 Error When Calling Azure Function with Query Parameters

vindicecodes 20 Reputation points
2024-03-18T15:52:59.7133333+00:00

Hello,

First time making a project in Azure Function Apps. Using GItHub CoPilot to code way beyond my means, but have been making pleasant progress. But stuck currently, can provide link to the GitHub Repo where project is stored, and open to any advice on how I could word this question better, or provide more relevant details to help troubleshoot.

I'm currently working on a project where I'm trying to pass parameters via a URL to an Azure Function. The function is part of a Function App that is intended to integrate with ViciDial. The parameters are passed in the URL as query parameters, and the function is supposed to process these parameters and perform certain actions.

Here's the URL format I'm using to call the function:

https://callhandling-development-test.azurewebsites.net/api/HttpTriggerViciDialIntegration?firstName=John&lastName=Doe&phoneNumber=1234567890

However, when I try to call the function using this URL, I get a 404 error. The error log of the HttpTriggerViciDialIntegration function doesn't show any attempts made to the function.

The URL To the Function App is Working, and the Function name is typed correctly, and the project directory on the repo is representative of the necessary file structure for Azure Function Apps.

Here's what I've checked so far:

  • The function app name and function name in the URL are correct.
  • The function has been successfully deployed to Azure.
  • The function code is correctly defined and doesn't have any errors. The only Problems that show in VSC are from Pylance errors stemming from python files created somehow, but i don't think this is the cause of the issue as this is python not the function code?
  • The function app is up and running in the Azure portal.
  • The function app is deployed in the East US region, and I'm accessing the correct URL for that region.
  • The FUNCTIONS_EXTENSION_VERSION is set to ~4.
  • Connection Strings are in Environment Settings and referenced correct.
  • Tried added error handling to the init.py but since the function never gets invoked, i can't see error logs.

I'm not using a custom route for the function, so the route in the URL should match the default route in the function configuration.

Here's an excerpt from the function code:

if not first_name or not last_name or not phone_number:

    return func.HttpResponse(

        "Please provide all required parameters: firstName, lastName, phoneNumber",

        status_code=400

    )

# Rest of the code...

I'm at a loss as to why I'm getting a 404 error. Any help would be greatly appreciated.

Thanks in advance!

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,909 questions
0 comments No comments
{count} votes

Accepted answer
  1. Ryan Hill 30,281 Reputation points Microsoft Employee Moderator
    2024-03-20T18:50:59.6066667+00:00

    Hi @vindicecodes,

    I can see that your function app is running. If you're hitting a 404, then I would suggest verifying the uri of the http trigger function. You can use az functionapp function list --resource-group <rg> --name callhandling-development-test --output table --query "[].invokeUrlTemplate" or on the Overview blade of the function app in the portal, click on Functions. In the portal, you can click the function and select Get Function Url to confirm the correct URL. You can also use the Code+Test option within the HTTP trigger function to invoke the function and observe any errors.

    If everything is written correctly, and the function is set for Anonymous access, then code may be failing to load when the trigger is invoked. The following, Troubleshoot Python function apps in Azure Functions | Microsoft Learn guide can help you determine why your python function is failing to invoke.


    EDIT 21 Mar 2024 Per our offline discussion, we noticed that your functions.json was missing "name": "$return" for the function output, where it was set to an empty string. Once you added that, you received HTTP500 errors which allowed you determine you were using UTF-16 encoding instead of UTF-8.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.