File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import azure .functions as func
22from copy_blobs .copy_blobs import copy_blobs_bp
33from http_trigger .http_trigger import http_bp
4+ from http_trigger_async .http_trigger_async import http_async_bp
45from http_trigger_async_exec .http_trigger_async_execution import http_async_exec_bp
56from simple_blob_trigger .simple_blob_trigger import simple_blob_trigger_bp
67from simple_blob_trigger_managed_identity .simple_blob_trigger_managed_identity import (
1516
1617app .register_functions (copy_blobs_bp )
1718app .register_functions (http_bp )
19+ app .register_functions (http_async_bp )
1820app .register_functions (http_async_exec_bp )
1921app .register_functions (simple_blob_trigger_bp )
2022app .register_functions (simple_blob_trigger_mi_bp )
Original file line number Diff line number Diff line change 1+ import aiohttp
2+ import azure .functions as func
3+
4+ http_async_bp = func .Blueprint ()
5+
6+
7+ @http_async_bp .route (route = "http_trigger_async" , auth_level = func .AuthLevel .ANONYMOUS )
8+ async def http_trigger_async (req : func .HttpRequest ) -> func .HttpResponse :
9+ url = req .params .get ("url" ) or req .get_json ().get ("url" )
10+ if not url :
11+ return func .HttpResponse (
12+ "Please pass a valid worldtimeapi url" ,
13+ status_code = 500 ,
14+ )
15+ async with aiohttp .ClientSession () as s :
16+ async with s .get (url ) as response :
17+ data = await response .json ()
18+ return func .HttpResponse (f"It is currently { data ['datetime' ]} " )
You can’t perform that action at this time.
0 commit comments