My function App is working fine locally, but it is not detecting any functions when uploaded to the cloud. I have reviewed the host.json, function.json, and function_app.py thoroughly.
The logs show that an http function is correctly routed when deleting and recreating the function. Yet, as soon as I do az functionapp deployment source config-zip
or func azure functionapp publish flag-function-app
, the function breaks and it stops detecting the http routed function.
Here is the last line of the "publish" command. As you caan see, no functions have been detected:
Remote build succeeded!
[2025-03-04T12:29:30.757Z] Syncing triggers...
Functions in flag-function-app:
*I tried setting "function.json" instead of "route" but that didn't resolve the issue either.
Lastly, here are the commands I am using for local test. Which is working:
func start
FOLDER STRUCTURE:
flag-function-app/
├─ function_app.py
├─ host.json
├─ requirements.txt
└─ flag_generation/
├── init.py
└── flag_creation.py
FUNCTION_APP.PY
import azure.functions as func
import logging
# Import the function from __init__.py
from flag_generation import main as flag_generation_main
app = func.FunctionApp()
@app.route(route="generate_flag", auth_level=func.AuthLevel.ANONYMOUS)
def generate_flag(req: func.HttpRequest) -> func.HttpResponse:
"""
Azure Function HTTP trigger that calls the correct function inside flag_generation/__init__.py.
"""
logging.info("Processing request via function_app.py...")
return flag_generation_main(req)
HOST.JSON
{
"version": "2.0",
"logging": {
"applicationInsights": {
"samplingSettings": {
"isEnabled": true,
"excludedTypes": "Request"
}
}
},
"extensionBundle": {
"id": "Microsoft.Azure.Functions.ExtensionBundle",
"version": "[4.*, 5.0.0)"
}
}
INIT.PY
import json
import azure.functions as func
import logging
from flag_generation.flag_creation import generate_and_store_flag # Import from flag_creation.py
def main(req: func.HttpRequest) -> func.HttpResponse:
"""
Azure Function that receives flag generation parameters,
calls OpenAI's API, stores the image in Azure Blob Storage,
and returns the final URL.
"""
logging.info("Processing a flag generation request inside flag_generation/__init__.py...")
try:
# Parse request body
req_body = req.get_json()
color = req_body.get("color", "").strip()
animal = req_body.get("animal", "").strip()
obj = req_body.get("object", "").strip()
# Ensure all parameters are provided
if not color or not animal or not obj:
return func.HttpResponse(
json.dumps({"error": "Missing required parameters: color, animal, object"}),
mimetype="application/json",
status_code=400
)
# Generate and store the image
image_url = generate_and_store_flag(color, animal, obj)
return func.HttpResponse(
json.dumps({"image_url": image_url}),
mimetype="application/json",
status_code=200
)
except Exception as e:
logging.error(f"Error generating flag: {str(e)}")
return func.HttpResponse(
json.dumps({"error": str(e)}),
mimetype="application/json",
status_code=500
)
REQUIREMENTS.TXT
azure-functions==1.15.0
azure-storage-blob==12.24.1
openai==1.63.0
requests
numpy==1.26.4
opencv-python==4.11.0.86