I have an Azure Http Trigger function, which builds successfully and runs without errors, but it’s not loading the function or functions.
The current run output gives out the following in verbose mode:
While testing the endpoint, using Postman, it gives me out of obvious reasons the 404 HTTP response.
Trying to resolve the issue I have tried multiple possibilities that can be related to the function itself, such as:
- Incorrect project type
- Missing function triggers, and any issues related to them
- Invalid function signatures
- Missing Nuget packages
- Incorrect local.settings.json
- Incorrect host.json
- Run configuration
- Going through verbose logs output on run and build for any pointers
Initial assumptions were that it was due to the function I was working on, but further investigations showed that it’s happening for all the local development functions that I want to run and debug locally(tried it in multiple IDEs and Terminal with a new test function). Which points to a more global issue.
Currently running it using JetRider but have also tried using Visual Studio and directly the command line execution.
The azure function using
Azure Functions Core Tools: 4.0.4915
Function Runtime Version: 4.14.0.19631
Framework: .net 6.0
Language: C#
Question:
What could be causing this and or how can it be resolved?
Update:
While investigating it was discovered that func
doesn’t read the host.json
and local.settings.json
from the project function root. How can this be corrected to read it from the project?
2
Answers
As none of the options worked, to correct the issue where the correct
host.json
file is read. Such as:local.appsettings.json
that would be used in thehost.json
Whereas I did not manage to find any documentation on what actually the tools and framework do in the background when the
host.json
is not found or it's there but ignored. Based on what was the output I can figure it is not an issue with the tools, but some configuration that caused it to ignore the host.json file, generate a new one and created it on top of that in the root of thebin
folder instead of the properdebug
orrelease
output folder where it would have been read.I decided to go with the basic approach of uninstalling all IDEs, including Visual Studio, JetRider, Visual Studio Code, and all instances of the Azure Functions Core Tools. This actually resolved the issue, and when installing all tools back, it still continued to work. I suspect this is a common framework approach in which it uses a similar approach for any default configuration files, when not present.
As a confirmation, Azure Functions do generate a new
host.json
file if one is not found or for some reason ignored, and that one is being used. But the way how it goes about it, I haven't still been able to find out.I took a .NET 6 Azure Function with an Http Trigger and run the function with the command
func host start --verbose
, then I got the below logs in the Console/Terminal:I have observer that before Generating and Validating the number of functions found in the project, Runtime Worker is reading the Function Metadata:
After I Created the 2nd Http Trigger Function in the Same project:
This Function metadata is specific to the trigger type such as Http, Queue, Blob Storage, etc.
For Http Trigger, it expects the Name, Type and Direction should be correctly mapped to the binding metadata as mentioned in this MS Doc 1 & 2
All these Bindings will be available in the Function Declaration for the Http Trigger Class File – cSharp Azure Function Created locally.
Here is the GitHub Repository, I have pushed my Azure Functions (.NET 6 Stack) – Http Trigger Project Code for your reference.