2 functions in azure function app works in local but not when deployed
I am trying to use selenium inside function app from a container azure container registry,
using python v2
this is the function_app.py
import logging
import azure.functions as func
import json
from Scraper import Scraper
from SeleniumSetup import SeleniumSetup
from LiveStreamRepository import LiveStreamRepository
import asyncio
import aiohttp
app = func.FunctionApp()
seleniumSetup= SeleniumSetup()
liveStreamRepo=LiveStreamRepository()
@app.route(route="ScrapKickStreamer", auth_level=func.AuthLevel.ANONYMOUS)
def ScrapKickStreamer(req: func.HttpRequest) -> func.HttpResponse:
streamer = req.params.get("streamer")
if streamer == None or streamer == "":
response = {"success": True, "data": None}
return func.HttpResponse(
json.dumps(response),
status_code=200,
)
try:
scraper = Scraper(streamer,seleniumSetup.get_firefox_driver(),liveStreamRepo)
state=scraper.run()
state=True
if(state):
response = {"success": True, "data":scraper.scraped_data}
return func.HttpResponse(
json.dumps(response),
)
else:
response = {"success": False, "data": None}
return func.HttpResponse(
json.dumps(response),
status_code=200,
)
except Exception as e:
return func.HttpResponse(f"This HTTP triggered function failed to execute.\n Error: {e}")
@app.schedule(schedule="* * * * *", arg_name="mytimer", run_on_startup=True, use_monitor=False)
async def schedule_scrapping(mytimer: func.TimerRequest) -> None:
try:
streamers= liveStreamRepo.fetch_streamers()
if(len(streamers)==0):
return
except Exception as e:
logging.error(f"An error occurred while fetching streamers: {e}")
return
base_url = 'http://localhost:7071/api/ScrapKickStreamer?streamer='
async with aiohttp.ClientSession() as session:
tasks = [fetch_scrapper(session, base_url + streamer) for streamer in streamers]
await asyncio.gather(*tasks)
liveStreamRepo.add_livestreams(liveStreamRepo.register)
liveStreamRepo.clear_register()
async def fetch_scrapper(session, url):
try:
async with session.get(url) as response:
result = await response.text()
print(f'Successfully fetched data for {url}')
except Exception as e:
print(f'Failed to fetch data for {url}: {e}')
locally everything works fine, scheduled function gets triggered when time comes up, and the http trigger function working fine as well.
when deployed I change the url in the scheduled function, to azure function app url.
and I get 404 error when I try to call the end point.
in Azure portal the functions doesn't even show up
this is dockerfile
and below the commands I use to push it to azure container registry
docker login "$acr_id" -u "$acr_username" -p "$acr_password"
docker build --tag "$acr_id/$image_name" .
docker push "$acr_id/$image_name:latest"
host.json
I didn't find how to track the issue, I get no errors in deployment. Any suggestions.
Azure function app can't support 2 functions inside of it in same function_app file ?if no how is it possible to work as expected in local?