Git Product home page Git Product logo

fastapi_azure's People

Contributors

ecerami avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

fastapi_azure's Issues

Error running external on Azure

Found your Medium post some months ago. Got the API working on Azure and running for a couple of months now, thanks for that.

But.. I tried to update the API today and pushed the new code to Azure and ended up with http 500 error codes. Seems to be an error in the http_asgi.py if i am not mistaken. This is the error i got from the Application Insights.

Do you know what the problem might be?

Exception while executing function: Functions.my-appname <--- Result: Failure Exception: TypeError: '<' not supported between instances of 'NoneType' and 'int' Stack: File "/azure-functions-host/workers/python/3.9/LINUX/X64/azure_functions_worker/dispatcher.py", line 402, in _handle__invocation_request call_result = await self._loop.run_in_executor( File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, **self.kwargs) File "/azure-functions-host/workers/python/3.9/LINUX/X64/azure_functions_worker/dispatcher.py", line 611, in _run_sync_func return ExtensionManager.get_sync_invocation_wrapper(context, File "/azure-functions-host/workers/python/3.9/LINUX/X64/azure_functions_worker/extension.py", line 215, in _raw_invocation_wrapper result = function(**args) File "/home/site/wwwroot/my-appname/__init__.py", line 230, in main return AsgiMiddleware(app).handle(req, context) File "/azure-functions-host/workers/python/3.9/LINUX/X64/azure/functions/_http_asgi.py", line 146, in handle return self._handle(req, context) File "/azure-functions-host/workers/python/3.9/LINUX/X64/azure/functions/_http_asgi.py", line 152, in _handle asgi_response = self._loop.run_until_complete( File "/usr/local/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete return future.result() File "/azure-functions-host/workers/python/3.9/LINUX/X64/azure/functions/_http_asgi.py", line 65, in from_app await app(scope, res._receive, res._send) File "/home/site/wwwroot/.python_packages/lib/site-packages/fastapi/applications.py", line 212, in __call__ await super().__call__(scope, receive, send) File "/home/site/wwwroot/.python_packages/lib/site-packages/starlette/applications.py", line 119, in __call__ await self.middleware_stack(scope, receive, send) File "/home/site/wwwroot/.python_packages/lib/site-packages/starlette/middleware/errors.py", line 181, in __call__ raise exc File "/home/site/wwwroot/.python_packages/lib/site-packages/starlette/middleware/errors.py", line 159, in __call__ await self.app(scope, receive, _send) File "/home/site/wwwroot/.python_packages/lib/site-packages/starlette/exceptions.py", line 87, in __call__ raise exc File "/home/site/wwwroot/.python_packages/lib/site-packages/starlette/exceptions.py", line 76, in __call__ await self.app(scope, receive, sender) File "/home/site/wwwroot/.python_packages/lib/site-packages/starlette/routing.py", line 659, in __call__ await route.handle(scope, receive, send) File "/home/site/wwwroot/.python_packages/lib/site-packages/starlette/routing.py", line 259, in handle await self.app(scope, receive, send) File "/home/site/wwwroot/.python_packages/lib/site-packages/starlette/routing.py", line 61, in app response = await func(request) File "/home/site/wwwroot/.python_packages/lib/site-packages/fastapi/routing.py", line 216, in app solved_result = await solve_dependencies( File "/home/site/wwwroot/.python_packages/lib/site-packages/fastapi/dependencies/utils.py", line 465, in solve_dependencies response = response or Response( File "/home/site/wwwroot/.python_packages/lib/site-packages/starlette/responses.py", line 50, in __init__ self.init_headers(headers) File "/home/site/wwwroot/.python_packages/lib/site-packages/starlette/responses.py", line 77, in init_headers and not (self.status_code < 200 or self.status_code in (204, 304))

Question/Error : No job functions found. Try making your job classes and methods public.

Hello,

I tried to follow your tutorial unfortunately, when I am running the azure function locally, I have this error in verbose mode:

[2022-02-20T18:36:52.519Z] Reading functions metadata
[2022-02-20T18:36:52.519Z] 0 functions found
[2022-02-20T18:36:52.538Z] 0 functions loaded
[2022-02-20T18:36:52.554Z] Generating 0 job function(s)
[2022-02-20T18:36:52.568Z] No job functions found. Try making your job classes and methods public. If you're using binding extensions (e.g. Azure Storage, ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup code (e.g. builder.AddAzureStorage(), builder.AddServiceBus(), builder.AddTimers(), etc.).

I don't understand why the app isn't loaded correctly while my configuration looks like this :
function.json

{
"scriptFile": "app.py",
"bindings": [
{
"authLevel": "anonymous",
"type": "httpTrigger",
"direction": "in",
"name": "req",
"methods": [
"get",
"post",
"put",
"patch",
"delete"
],
"route": "/{*route}"
},
{
"type": "http",
"direction": "out",
"name": "$return"
}
]

}

app.py

import azure.functions as func
from http_asgi import AsgiMiddleware

from app import app

def main(req: func.HttpRequest, context: func.Context) -> func.HttpResponse:
return AsgiMiddleware(app).handle(req, context)

app/init.py

from fastapi import FastAPI, Depends

from app.auth.jwt_bearer import JWTBearer
from app.routes.device import router as device_router
from app.routes.auth import router as admin_router
from app.routes.user import router as user_router
from app.routes.transceiver import router as transceiver_router

app = FastAPI()

token_listener = JWTBearer()

app.include_router(admin_router, tags=["Auth"], prefix="/auth")
app.include_router(user_router, tags=["Users"], prefix="/users", dependencies=[Depends(token_listener)])
app.include_router(device_router, tags=["Devices"], prefix="/devices", dependencies=[Depends(token_listener)])
app.include_router(user_router, tags=["Transceivers"], prefix="/transceivers", dependencies=[Depends(token_listener)])

Could you please have a look and help me on this one?

Thank you,
Romain

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.