Open lac-anakagawa opened 10 months ago
Can confirm this behaviour. Only works with an empty string for routePrefix
.
However, if routePrefix
is empty in the host.json
, then the GitHub action static-web-apps-deploy@v1 will throw:
Error in processing api build artifacts: the host.json file cannot specify a http.routePrefix value other than 'api'.
Because all endpoints should be defined with api/.
In other words:
Not sure this helps anyone but if you deploy the backend as a separate function app, you can set the prefix to an empty string and make everything work.
I think the easiest way to fix this would be to remove the thrown error from the GitHub workflow. As far as I understand it should be a warning anyway. Simply rely on users setting all api paths under /api
. All other routes will simply not work.
@pietz Could you share how to remove the thrown error? After removing, will it work after static-web-apps-deploy@v1?
Can this issue get more attention please? Not being able to lift & shift your fastAPI (or any other?) application is such an bummer..
Confirm, Error is still present.
Azure Functions + fastAPI + v2 Python model + Azure Static Web App
Wanted to deploy a demo Angular + FastAPI & GenAI.
Any update on this...?
For the time being I manually patched this by removing the excess "/" in route="/{*route}" in http_app_func's decorator under the AsgiFunctionApp class. It's a terrible solution. I hope this is fixed soon.
@bhagyshricompany Any updates? This ought to be fixed sooner than later.
Investigative information
Please provide the following:
Repro steps
Provide the steps required to reproduce the problem:
func init <> --worker-runtime python --model V2
function_app.py
, create a new ASGI Function App with the following code:from fastapi import FastAPI
api = FastAPI()
@api.get("/") def root(): return {"message": "Hello World"}
@api.get("/healthcheck") def healthcheck(): return 1
app = func.AsgiFunctionApp( app=api, http_auth_level=func.AuthLevel.ANONYMOUS )
"extensions": { "http": { "routePrefix": "api" } }
❯ func start Found Python version 3.10.11 (py).
Azure Functions Core Tools Core Tools Version: 4.0.5274 Commit hash: N/A (64-bit) Function Runtime Version: 4.23.0.20886
[2023-08-28T23:02:24.316Z] Worker process started and initialized. [2023-08-28T23:02:24.385Z] A host error has occurred during startup operation 'a87fe4da-9c2c-4dd7-958f-c9b73021ea2c'. [2023-08-28T23:02:24.387Z] Microsoft.AspNetCore.Routing: An error occurred while creating the route with name 'http_app_func' and template 'api//{*route}'. Microsoft.AspNetCore.Routing: The route template separator character '/' cannot appear consecutively. It must be separated by either a parameter or a literal value. (Parameter 'routeTemplate'). Microsoft.AspNetCore.Routing: The route template separator character '/' cannot appear consecutively. It must be separated by either a parameter or a literal value. [2023-08-28T23:02:24.399Z] Failed to stop host instance '4b8b0863-dcb1-4a41-9b70-0beaad496108'. [2023-08-28T23:02:24.401Z] Microsoft.Azure.WebJobs.Host: The host has not yet started. Value cannot be null. (Parameter 'provider') [2023-08-28T23:02:24.409Z] Host startup operation has been canceled
{ "version": "2.0", "logging": { "applicationInsights": { "samplingSettings": { "isEnabled": true, "excludedTypes": "Request" } } }, "extensionBundle": { "id": "Microsoft.Azure.Functions.ExtensionBundle", "version": "[4.*, 5.0.0)" }, "extensions": { "http": { "routePrefix": "" } } }
azure-functions azure-storage-blob==12.1.0
azure-functions fastapi==0.103.0