Azure-Functions icon indicating copy to clipboard operation
Azure-Functions copied to clipboard

No HTTP Trigger Found When Deploying FastAPI Azure Function (Python v2)

Open yalcinsabancelebi opened this issue 8 months ago • 5 comments

Hello,

I’m using the Python v2 programming model in Azure Functions along with FastAPI. I’ve been successfully deploying my project until recently, when I began receiving this error during deployment:

No HTTP triggers found.

Here’s the full context:


I have not changed any of the following:

  • host.json
  • local.settings.json
  • VS Code config files
  • Azure Portal > Function App settings (Application Settings)

The only changes I've made are inside function_app.py and main.py (where FastAPI is used).


function_app.py

import azure.functions as func
from main import app as main

app = func.AsgiFunctionApp(app=main, http_auth_level=func.AuthLevel.ANONYMOUS)

@app.function_name(name="MatchTimerTriggerFunction")
@app.schedule(schedule="0 * * * * *", arg_name="myTimer", run_on_startup=False, use_monitor=True)
async def fifteen_timetrigger(myTimer: func.TimerRequest):
    if myTimer:
        print("Match Timer Trigger Function")

@app.function_name(name="CountdownTriggerFunction")
@app.schedule(schedule="0 * * * * *", arg_name="myTimer", run_on_startup=False, use_monitor=True)
async def countdown_timer(myTimer: func.TimerRequest):
    if myTimer:
        print("Countdown Timer Trigger Function")

@app.function_name(name="ExpiredMatchesTriggerFunction")
@app.schedule(schedule="0 * * * * *", arg_name="myTimer", run_on_startup=False, use_monitor=True)
async def countdown_timer(myTimer: func.TimerRequest):
    if myTimer:
        print("Expired Matches Trigger Function")

main.py (FastAPI Entry)

import fastapi
from fastapi.middleware.cors import CORSMiddleware

app = fastapi.FastAPI(...)

app.add_middleware(CORSMiddleware, ...)

from api.v1.homepage import router as homepage
app.include_router(homepage, prefix="/api/v1/homepage", tags=["Homepage"])

@app.get("/")
async def test():
    return {"message": "test"}

Project is modular. Example FastAPI route:

# api/v1/homepage/__init__.py
from fastapi import APIRouter, Depends, Query, Header
from fastapi.security import OAuth2PasswordBearer
from schemas.responses import StandardResponse

router = APIRouter()
oauth2_scheme = OAuth2PasswordBearer(tokenUrl="auth/login")

@router.get("", response_model=StandardResponse)
async def homepage(token: str = Depends(oauth2_scheme), timezone: str = Query(...), language: str = Header("en")):
    return StandardResponse(status="success", statusCode=200, data="homepage")

Everything works locally via func start.


Application Settings (Azure Portal) are verified:

  • CosmosDB
  • Blob Storage
  • Application Insights
  • AzureWebJobsStorage
  • AzureWebJobsFeatureFlags = EnableWorkerIndexing

Dependencies (requirements.txt) are valid

  • Fresh virtual environment installs correctly
  • pip freeze matches expected output

Deployment Behavior

Sometimes deployment works and I see:

HTTP Trigger Urls:
  http_app_func: https://fifteen.azurewebsites.net//%7B*route%7D

But even with a minor change (like a print() statement), I get:

No HTTP triggers found.

Relevant Config Files

host.json

{
  "version": "2.0",
  "functionTimeout": "00:05:00",
  "extensions": {
    "http": {
      "routePrefix": ""
    }
  },
  "logging": {
    "applicationInsights": {
      "samplingSettings": {
        "isEnabled": true,
        "excludedTypes": "Request"
      }
    }
  },
  "extensionBundle": {
    "id": "Microsoft.Azure.Functions.ExtensionBundle",
    "version": "[4.*, 5.0.0)"
  }
}

local.settings.json

{
  "IsEncrypted": false,
  "Values": {
    "AzureWebJobsFeatureFlags": "EnableWorkerIndexing",
    "AzureWebJobsStorage": "<valid>",
    "FUNCTIONS_WORKER_RUNTIME": "python",
    "fifteen_DOCUMENTDB": "<valid>"
  },
  "ConnectionStrings": {}
}

function.json

{
  "scriptFile": "function_app.py",
  "bindings": [
    {
      "type": "httpTrigger",
      "direction": "in",
      "name": "req",
      "methods": ["get", "post", "delete", "options"],
      "authLevel": "anonymous"
    },
    {
      "type": "http",
      "direction": "out",
      "name": "$return"
    }
  ]
}

here is my file structure:

Image

@eylulonar @frkinal


yalcinsabancelebi avatar May 15 '25 10:05 yalcinsabancelebi

I am seeing similar behavior, since last approx 10 days, see #2608

Some Old issues talk about startup problems, if module cryptography==44.0.0 is installed via requirements.txt I changed that in my deployment to cryptography==43.0.3. still some issues. so this is not it.

to compare notes, which plan your function is using?

nimbusnext-malhar avatar May 15 '25 14:05 nimbusnext-malhar

I am seeing similar behavior, since last approx 10 days, see #2608

Some Old issues talk about startup problems, if module cryptography==44.0.0 is installed via requirements.txt I changed that in my deployment to cryptography==43.0.3. still some issues. so this is not it.

to compare notes, which plan your function is using?

firstly thanks your attention. yes i have using but this lib but always used as cryptography==43.0.3 in my requirements file and have never changed it

yalcinsabancelebi avatar May 15 '25 18:05 yalcinsabancelebi

I am seeing similar behavior, since last approx 10 days, see #2608

Some Old issues talk about startup problems, if module cryptography==44.0.0 is installed via requirements.txt I changed that in my deployment to cryptography==43.0.3. still some issues. so this is not it.

to compare notes, which plan your function is using?

btw i'm using premium EP1 function app plan

yalcinsabancelebi avatar May 15 '25 18:05 yalcinsabancelebi

I see this behavior on Consumption Plan, as well as running on App service Plans

But the bare-code version which I test works on consumption plan

Where I have some dependencies, that version does not work anywhere but local. And I have neither time nor patience to maybe hunt one dependency via running different permutations of dependencies

I am seeing similar behavior, since last approx 10 days, see #2608 Some Old issues talk about startup problems, if module cryptography==44.0.0 is installed via requirements.txt I changed that in my deployment to cryptography==43.0.3. still some issues. so this is not it. to compare notes, which plan your function is using?

btw i'm using premium EP1 function app plan

nimbusnext-malhar avatar May 15 '25 18:05 nimbusnext-malhar

Maybe you can create a new venv file and new python environment good idea for your case as fresh start. Than use pip freeze and try deploy console command as func azure functionapp publish <your func app name>

yalcinsabancelebi avatar May 15 '25 18:05 yalcinsabancelebi