Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

routePrefix is being ignored on Azure function app

It appears the routePrefix is being ignored on my function app. It shows in the console output that the configuration file is being read successfully:

info: Host.Startup[0]
      Host configuration file read:
      {
        "version": "2.0",
        "http": {
          "routePrefix": "",
          "maxOutstandingRequests": 20,
          "maxConcurrentRequests": 10,
          "dynamicThrottlesEnabled": false
        }
      }
[9/3/18 9:33:52 PM] Initializing Host.
[9/3/18 9:33:52 PM] Host initialization: ConsecutiveErrors=0, StartupCount=1
[9/3/18 9:33:52 PM] Starting JobHost
[9/3/18 9:33:52 PM] Starting Host (HostId=fractalnode-520849571, InstanceId=3e35830d-fd9d-4235-ae6a-7d1b356db04a, Version=2.0.12050.0, ProcessId=36292, AppDomainId=1, Debug=False, FunctionsExtensionVersion=)
[9/3/18 9:33:52 PM] Starting language worker process:node  "C:\Users\ben\AppData\Roaming\npm\node_modules\azure-functions-core-tools\bin\workers\node\dist/src/nodejsWorker.js" --host 127.0.0.1 --port 50880 --workerId 1f503d98-7661-4a40-83cd-ee19d9a48751 --requestId 9a6ef97a-b016-4554-904b-db43e3f4262c --grpcMaxMessageLength 134217728
[9/3/18 9:33:52 PM] node process with Id=36800 started
[9/3/18 9:33:52 PM] Generating 1 job function(s)
[9/3/18 9:33:52 PM] Found the following functions:
[9/3/18 9:33:52 PM] Host.Functions.serverTrigger
[9/3/18 9:33:52 PM]
[9/3/18 9:33:52 PM] Host initialized (196ms)
[9/3/18 9:33:52 PM] Host started (203ms)
[9/3/18 9:33:52 PM] Job host started
Hosting environment: Production
Content root path: c:\proj\directalert\www
Now listening on: http://0.0.0.0:7071
Application started. Press Ctrl+C to shut down.
Listening on http://0.0.0.0:7071/
Hit CTRL-C to exit...

but then it still has the /api prefix even though it should be ""

Http Functions:
        serverTrigger: http://localhost:7071/api/{*segments}

Also, changing the routePrefix to '/' or '/apiprefixtest' doesn't make any difference either.

Any idea why the routePrefix is being ignored by the Azure Functions runtime?

like image 690
Ben H Avatar asked Sep 03 '18 22:09

Ben H


People also ask

How do I pass the function key to Azure function?

These keys are passed on to the URL of Azure Function Trigger URL in the form of Query String. The alternative way is passing the key value in the x-functions-key HTTP header. Function authorization level requires an authorization key which can works using both the Function Level and Host Level Keys.

Can we call API from Azure function?

Depending upon your requirement you can create any of supported trigger to trigger your function app and your function app code will make the HTTP calls. You can refer to Call a Web API From a . NET Client (C#) document for more details.


1 Answers

I see that you are using Version 2.0. Schema has changed for V2, so just add the "extensions" as shown below:

{
    "version": "2.0",
        "extensions": {
            "http": {
                "routePrefix": "",
                "maxOutstandingRequests": 20,
                "maxConcurrentRequests": 10,
                "dynamicThrottlesEnabled": false
            }
    }
} 

There are some breaking changes there in V2, so do take a look at this documentation and you might find some more relevant changes -

Azure Functions Runtime 2.0.12050-alpha breaking changes notice

And here is a link from within the article mentioned above specific to application -

All application-level extension settings now live under "extensions"

like image 78
Rohit Saigal Avatar answered Sep 18 '22 05:09

Rohit Saigal