skip to Main Content

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:
Run output

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


  1. Chosen as BEST ANSWER

    As none of the options worked, to correct the issue where the correct host.json file is read. Such as:

    • Update all tools
    • Check all configurations that the project itself has
    • Confirm that this is a local issue and not a project issue
    • Check with different Azure Functions Core Tools
    • Reconfigure to use configuration options in the local.appsettings.json that would be used in the host.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 the bin folder instead of the proper debug or release 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.


  2. 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:

    PS C:UsersHariAzure FunctionsKrishNet6FunApp104> func host start --verbose
    MSBuild version 17.4.1+9a89d02ff for .NET
      Determining projects to restore...
      All projects are up-to-date for restore.
      KrishNet6FunApp104 -> C:UsersHariAzure FunctionsKrishNet6FunApp104binoutputKrishNet6FunApp104.dll
    
    Build succeeded.
        0 Warning(s)
        0 Error(s)
    
    Time Elapsed 00:00:14.49
    
    
    
                      %%%%%%
                     %%%%%%
                @   %%%%%%    @
              @@   %%%%%%      @@
           @@@    %%%%%%%%%%%    @@@
         @@      %%%%%%%%%%        @@
           @@         %%%%       @@
             @@      %%%       @@
               @@    %%      @@
                    %%
                    %
    
    
    Azure Functions Core Tools
    Core Tools Version:       4.0.4915 Commit hash: N/A  (64-bit)
    Function Runtime Version: 4.14.0.19631
    
    [2023-02-14T07:11:40.662Z] Found C:UsersHariAzure FunctionsKrishNet6FunApp104KrishNet6FunApp104.csproj. Using for user secrets file configuration.
    [2023-02-14T07:11:42.596Z] Building host: version spec: , startup suppressed: 'False', configuration suppressed: 'False', startup operation id: '6d9cc98b-20c2-463b-822a-05cf23ae8998'
    [2023-02-14T07:11:42.617Z] Reading host configuration file 'C:UsersHariAzure FunctionsKrishNet6FunApp104binoutputhost.json'
    [2023-02-14T07:11:42.622Z] Host configuration file read:
    [2023-02-14T07:11:42.624Z] {
    [2023-02-14T07:11:42.626Z]   "version": "2.0",
    [2023-02-14T07:11:42.627Z]   "logging": {
    [2023-02-14T07:11:42.628Z]     "applicationInsights": {
    [2023-02-14T07:11:42.630Z]       "samplingSettings": {
    [2023-02-14T07:11:42.631Z]         "isEnabled": true,
    [2023-02-14T07:11:42.633Z]         "excludedTypes": "Request"
    [2023-02-14T07:11:42.635Z]       }
    [2023-02-14T07:11:42.636Z]     }
    [2023-02-14T07:11:42.638Z]   }
    [2023-02-14T07:11:42.639Z] }
    [2023-02-14T07:11:42.671Z] Loading extensions from C:UsersHariAzure FunctionsKrishNet6FunApp104binoutputbin. BundleConfigured: False, PrecompiledFunctionApp: False, LegacyBundle: False
    [2023-02-14T07:11:42.674Z] Script Startup resetting load context with base path: 'C:UsersHariAzure FunctionsKrishNet6FunApp104binoutputbin'.
    [2023-02-14T07:11:42.707Z] Reading host configuration file 'C:UsersHariAzure FunctionsKrishNet6FunApp104binoutputhost.json'
    [2023-02-14T07:11:42.709Z] Host configuration file read:
    [2023-02-14T07:11:42.711Z] {
    [2023-02-14T07:11:42.714Z]   "version": "2.0",
    [2023-02-14T07:11:42.716Z]   "logging": {
    [2023-02-14T07:11:42.717Z]     "applicationInsights": {
    [2023-02-14T07:11:42.719Z]       "samplingSettings": {
    [2023-02-14T07:11:42.721Z]         "isEnabled": true,
    [2023-02-14T07:11:42.723Z]         "excludedTypes": "Request"
    [2023-02-14T07:11:42.724Z]       }
    [2023-02-14T07:11:42.725Z]     }
    [2023-02-14T07:11:42.727Z]   }
    [2023-02-14T07:11:42.728Z] }
    [2023-02-14T07:11:43.950Z] Initializing Warmup Extension.
    [2023-02-14T07:11:44.090Z] Initializing Host. OperationId: '6d9cc98b-20c2-463b-822a-05cf23ae8998'.
    [2023-02-14T07:11:44.115Z] Host initialization: ConsecutiveErrors=0, StartupCount=1, OperationId=6d9cc98b-20c2-463b-822a-05cf23ae8998
    [2023-02-14T07:11:44.173Z] LoggerFilterOptions
    [2023-02-14T07:11:44.174Z] {
    [2023-02-14T07:11:44.176Z]   "MinLevel": "None",
    [2023-02-14T07:11:44.178Z]   "Rules": [
    [2023-02-14T07:11:44.180Z]     {
    [2023-02-14T07:11:44.182Z]       "ProviderName": null,
    [2023-02-14T07:11:44.183Z]       "CategoryName": null,
    [2023-02-14T07:11:44.185Z]       "LogLevel": null,
    [2023-02-14T07:11:44.187Z]       "Filter": "<AddFilter>b__0"
    [2023-02-14T07:11:44.190Z]     },
    [2023-02-14T07:11:44.192Z]     {
    [2023-02-14T07:11:44.193Z]       "ProviderName": "Microsoft.Azure.WebJobs.Script.WebHost.Diagnostics.SystemLoggerProvider",
    [2023-02-14T07:11:44.195Z]       "CategoryName": null,
    [2023-02-14T07:11:44.197Z]       "LogLevel": "None",
    [2023-02-14T07:11:44.199Z]       "Filter": null
    [2023-02-14T07:11:44.200Z]     },
    [2023-02-14T07:11:44.202Z]     {
    [2023-02-14T07:11:44.204Z]       "ProviderName": "Microsoft.Azure.WebJobs.Script.WebHost.Diagnostics.SystemLoggerProvider",
    [2023-02-14T07:11:44.206Z]       "CategoryName": null,
    [2023-02-14T07:11:44.208Z]       "LogLevel": null,
    [2023-02-14T07:11:44.210Z]       "Filter": "<AddFilter>b__0"
    [2023-02-14T07:11:44.212Z]     },
    [2023-02-14T07:11:44.214Z]     {
    [2023-02-14T07:11:44.216Z]       "ProviderName": "Azure.Functions.Cli.Diagnostics.ColoredConsoleLoggerProvider",
    [2023-02-14T07:11:44.218Z]       "CategoryName": null,
    [2023-02-14T07:11:44.220Z]       "LogLevel": null,
    [2023-02-14T07:11:44.222Z]       "Filter": "<AddFilter>b__0"
    [2023-02-14T07:11:44.224Z]     }
    [2023-02-14T07:11:44.226Z]   ]
    [2023-02-14T07:11:44.231Z] }
    [2023-02-14T07:11:44.234Z] LoggerFilterOptions
    [2023-02-14T07:11:44.236Z] {
    [2023-02-14T07:11:44.238Z]   "MinLevel": "None",
    [2023-02-14T07:11:44.241Z]   "Rules": [
    [2023-02-14T07:11:44.243Z]     {
    [2023-02-14T07:11:44.245Z]       "ProviderName": null,
    [2023-02-14T07:11:44.249Z]       "CategoryName": null,
    [2023-02-14T07:11:44.251Z]       "LogLevel": null,
    [2023-02-14T07:11:44.253Z]       "Filter": "<AddFilter>b__0"
    [2023-02-14T07:11:44.255Z]     },
    [2023-02-14T07:11:44.260Z]     {
    [2023-02-14T07:11:44.266Z]       "ProviderName": "Microsoft.Azure.WebJobs.Script.WebHost.Diagnostics.SystemLoggerProvider",
    [2023-02-14T07:11:44.268Z]       "CategoryName": null,
    [2023-02-14T07:11:44.271Z]       "LogLevel": "None",
    [2023-02-14T07:11:44.274Z]       "Filter": null
    [2023-02-14T07:11:44.276Z]     },
    [2023-02-14T07:11:44.278Z]     {
    [2023-02-14T07:11:44.281Z]       "ProviderName": "Microsoft.Azure.WebJobs.Script.WebHost.Diagnostics.SystemLoggerProvider",
    [2023-02-14T07:11:44.283Z]       "CategoryName": null,
    [2023-02-14T07:11:44.286Z]       "LogLevel": null,
    [2023-02-14T07:11:44.288Z]       "Filter": "<AddFilter>b__0"
    [2023-02-14T07:11:44.291Z]     },
    [2023-02-14T07:11:44.294Z]     {
    [2023-02-14T07:11:44.297Z]       "ProviderName": "Azure.Functions.Cli.Diagnostics.ColoredConsoleLoggerProvider",
    [2023-02-14T07:11:44.300Z]       "CategoryName": null,
    [2023-02-14T07:11:44.303Z]       "LogLevel": null,
    [2023-02-14T07:11:44.305Z]       "Filter": "<AddFilter>b__0"
    [2023-02-14T07:11:44.310Z]     }
    [2023-02-14T07:11:44.313Z]   ]
    [2023-02-14T07:11:44.315Z] }
    [2023-02-14T07:11:44.317Z] ConcurrencyOptions
    [2023-02-14T07:11:44.320Z] {
    [2023-02-14T07:11:44.322Z]   "DynamicConcurrencyEnabled": false,
    [2023-02-14T07:11:44.326Z]   "MaximumFunctionConcurrency": 500,
    [2023-02-14T07:11:44.332Z]   "CPUThreshold": 0.8,
    [2023-02-14T07:11:44.335Z]   "SnapshotPersistenceEnabled": true
    [2023-02-14T07:11:44.337Z] }
    [2023-02-14T07:11:44.339Z] FunctionResultAggregatorOptions
    [2023-02-14T07:11:44.343Z] {
    [2023-02-14T07:11:44.346Z]   "BatchSize": 1000,
    [2023-02-14T07:11:44.350Z]   "FlushTimeout": "00:00:30",
    [2023-02-14T07:11:44.353Z]   "IsEnabled": true
    [2023-02-14T07:11:44.357Z] }
    [2023-02-14T07:11:44.361Z] SingletonOptions
    [2023-02-14T07:11:44.366Z] {
    [2023-02-14T07:11:44.372Z]   "LockPeriod": "00:00:15",
    [2023-02-14T07:11:44.376Z]   "ListenerLockPeriod": "00:00:15",
    [2023-02-14T07:11:44.379Z]   "LockAcquisitionTimeout": "10675199.02:48:05.4775807",
    [2023-02-14T07:11:44.383Z]   "LockAcquisitionPollingInterval": "00:00:05",
    [2023-02-14T07:11:44.385Z]   "ListenerLockRecoveryPollingInterval": "00:01:00"
    [2023-02-14T07:11:44.387Z] }
    [2023-02-14T07:11:44.393Z] Starting JobHost
    [2023-02-14T07:11:44.405Z] Starting Host (HostId=c1ml47687ms-778510111, InstanceId=454fc6f1-0750-4023-b206-73112827b0d6, Version=4.14.0.19631, ProcessId=5892, AppDomainId=1, InDebugMode=False, InDiagnosticMode=False, FunctionsExtensionVersion=(null))
    [2023-02-14T07:11:44.483Z] Loading functions metadata
    [2023-02-14T07:11:44.491Z] Reading functions metadata
    [2023-02-14T07:11:44.497Z] Reading functions metadata
    [2023-02-14T07:11:44.524Z] 1 functions found
    [2023-02-14T07:11:44.531Z] 1 functions found
    [2023-02-14T07:11:44.566Z] Reading functions metadata
    [2023-02-14T07:11:44.622Z] 1 functions found
    [2023-02-14T07:11:44.626Z] 1 functions loaded
    [2023-02-14T07:11:45.667Z] Generating 1 job function(s)
    [2023-02-14T07:11:45.771Z] Found the following functions:
    [2023-02-14T07:11:45.773Z] KrishNet6FunApp104.Function1.Run
    [2023-02-14T07:11:45.775Z]
    [2023-02-14T07:11:45.805Z] HttpOptions
    [2023-02-14T07:11:45.807Z] {
    [2023-02-14T07:11:45.809Z]   "DynamicThrottlesEnabled": false,
    [2023-02-14T07:11:45.810Z] Initializing function HTTP routes
    [2023-02-14T07:11:45.812Z]   "EnableChunkedRequestBinding": false,
    [2023-02-14T07:11:45.814Z] Mapped function route 'api/Function1' [get,post] to 'Function1'
    [2023-02-14T07:11:45.816Z]   "MaxConcurrentRequests": -1,
    [2023-02-14T07:11:45.818Z]
    [2023-02-14T07:11:45.820Z]   "MaxOutstandingRequests": -1,
    [2023-02-14T07:11:45.825Z]   "RoutePrefix": "api"
    [2023-02-14T07:11:45.830Z] }
    [2023-02-14T07:11:45.855Z] Host initialized (1410ms)
    [2023-02-14T07:11:45.865Z] Host started (1453ms)
    [2023-02-14T07:11:45.868Z] Job host started
    
    Functions:
    
            Function1: [GET,POST] http://localhost:7071/api/Function1
    

    I have observer that before Generating and Validating the number of functions found in the project, Runtime Worker is reading the Function Metadata:
    enter image description here

    After I Created the 2nd Http Trigger Function in the Same project:

    [2023-02-14T08:45:23.800Z] Starting JobHost
    [2023-02-14T08:45:23.804Z] Starting Host (HostId=c1ml47687ms-778510111, InstanceId=08cbea94-a74d-4167-892f-9802ed417b9a, Version=4.14.0.19631, ProcessId=18812, AppDomainId=1, InDebugMode=False, InDiagnosticMode=False, FunctionsExtensionVersion=(null))
    [2023-02-14T08:45:23.829Z] Loading functions metadata
    [2023-02-14T08:45:23.834Z] Reading functions metadata
    [2023-02-14T08:45:23.837Z] Reading functions metadata
    [2023-02-14T08:45:23.849Z] 2 functions found
    [2023-02-14T08:45:23.854Z] 2 functions found
    [2023-02-14T08:45:23.867Z] Reading functions metadata
    [2023-02-14T08:45:23.882Z] 1 functions found
    [2023-02-14T08:45:23.886Z] 2 functions loaded
    [2023-02-14T08:45:24.100Z] Generating 2 job function(s)
    [2023-02-14T08:45:24.145Z] Found the following functions:
    [2023-02-14T08:45:24.147Z] KrishNet6FunApp104.Function1.Run
    [2023-02-14T08:45:24.149Z] Company.Function.Function2.Run
    [2023-02-14T08:45:24.150Z]
    [2023-02-14T08:45:24.161Z] HttpOptions
    [2023-02-14T08:45:24.163Z] Initializing function HTTP routes
    [2023-02-14T08:45:24.163Z] {
    [2023-02-14T08:45:24.165Z] Mapped function route 'api/Function1' [get,post] to 'Function1'
    [2023-02-14T08:45:24.168Z]   "DynamicThrottlesEnabled": false,
    [2023-02-14T08:45:24.169Z] Mapped function route 'api/Function2' [get,post] to 'Function2'
    [2023-02-14T08:45:24.170Z]   "EnableChunkedRequestBinding": false,
    [2023-02-14T08:45:24.171Z]
    [2023-02-14T08:45:24.172Z]   "MaxConcurrentRequests": -1,
    [2023-02-14T08:45:24.174Z]   "MaxOutstandingRequests": -1,
    [2023-02-14T08:45:24.175Z]   "RoutePrefix": "api"
    [2023-02-14T08:45:24.176Z] }
    [2023-02-14T08:45:24.185Z] Host initialized (365ms)
    [2023-02-14T08:45:24.192Z] Host started (384ms)
    [2023-02-14T08:45:24.194Z] Job host started
    
    Functions:
    
            Function1: [GET,POST] http://localhost:7071/api/Function1
            Function2: [GET,POST] http://localhost:7071/api/Function2
    
    

    enter image description here

    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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search