I am new to Azure Functions and have successfully deployed a single Function App containing two functions. However, my requirements have changed, and I now need to have two separate Function Apps, each containing a single function.
I am struggling to understand how to structure the project to accommodate multiple Function Apps within a single repository. I have not found much helpful information in the Azure documentation regarding this specific scenario.
Below is the project structure and configuration for single and multiple Function App. I am looking for suggestions on how best to implement it according to best practices.
I managed to successfully deploy the second scenario but the function does not work, so I do not know if I forgot to define something or the path is wrong.
1 Function App 2 functions
function_app.py
import azure.functions as func
from function_app_blueprints.http_chatbot_industri import bp as http_chatbot_industri_bp
from function_app_blueprints.http_chatbot_babo import bp as http_chatbot_babo_bp
2 Azure Function Apps with single function in it
function_app_babo/function_app.py
import azure.functions as func
import logging
from src.chatbot_core.chatbot import Chatbot
from src.common.logging_utils import get_logger
app = func.FunctionApp(http_auth_level=func.AuthLevel.FUNCTION)
@app.function_name(name="fun_bamagpt_babo")
@app.route(route="ask_question")
def ask_question(req: func.HttpRequest) -> func.HttpResponse:
logging.info('Python HTTP trigger function processed a request.')
logger = get_logger(__name__)
chatbot = Chatbot(logger)
logging.info("Initilization completed...")
# Get question
req_body = {}
question = req.params.get('question')
if not question:
try:
req_body = req.get_json()
except ValueError:
pass
else:
question = req_body.get('question')
logging.info(f'question: {question}')
app = func.FunctionApp(http_auth_level=func.AuthLevel.FUNCTION)
app.register_functions(http_chatbot_industri_bp)
app.register_functions(http_chatbot_babo_bp)