Код: Выделить всё
import logging
from fastapi import FastAPI
import azure.functions as func
from schemas.schema import classSchemaReq
logging.basicConfig()
logger = logging.getLogger()
logger.setLevel(logging.INFO)
fast_app = FastAPI()
@fast_app.post("/execute_file")
async def execute_file(request: classSchemaReq):
return True
func_app = func.FunctionApp(http_auth_level=func.AuthLevel.ANONYMOUS)
@func_app.function_name(name="fastapi_http_trigger")
@func_app.route(route="execute_file")
async def main(req: func.HttpRequest, context: func.Context) -> func.HttpResponse:
"""Each request is redirected to the ASGI handler."""
return await func.AsgiMiddleware(fast_app).handle(req, context)
# @func_app.route(route="hello") # HTTP Trigger
# def test_function(req: func.HttpRequest) -> func.HttpResponse:
# return func.HttpResponse("HttpTrigger function processed a request!!!")
@func_app.cosmos_db_trigger(arg_name="azcosmosdb", container_name="ABC",
database_name="ABC", connection="ABC_DB_CONN")
def cosmosdb_trigger(azcosmosdb: func.DocumentList):
logging.info('Python CosmosDB triggered.')
Код: Выделить всё
[2024-10-12T12:18:07.653Z] return protos.StreamingMessage(
[2024-10-12T12:18:07.655Z] RuntimeWarning: Enable tracemalloc to get the object allocation traceback
[2024-10-12T12:18:07.685Z] Executed 'Functions.fastapi_http_trigger' (Failed, Id=7ec5c000-2b7d-45db-b6a4-5797aca47e19, Duration=138ms)
[2024-10-12T12:18:07.687Z] System.Private.CoreLib: Exception while executing function: Functions.fastapi_http_trigger. System.Private.CoreLib: Result: Failure
Буду очень признателен за любую помощь.
Подробнее здесь: https://stackoverflow.com/questions/790 ... db-trigger