My function app is not working in the cloud, but working fine locally

Juan Vergara 5 Reputation points
2025-03-04T12:09:18.5366667+00:00

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
Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,504 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Shireesha Eeraboina 1,900 Reputation points Microsoft External Staff
    2025-03-06T08:44:52.38+00:00

    Hi @Juan Vergara ,

    Thank you for your patience and for sharing your feedback on the Q&A community platform. I’m glad to hear that you were able to resolve your issue, and I appreciate you sharing your solution! Your contribution is valuable and can help others in the community facing similar challenges.

    As per the Microsoft Q&A community policy, "The question author cannot accept their own answer. They can only accept answers by others"

    I’m reposting your solution here so you can mark it as accepted if it resolves your query:

    "Deleting and recreating the function app resolved the issue".

    If you have any other questions, please let me know. Thank you again for your time and patience throughout this issue. 

    Please don’t forget to Accept Answer and Yes for "was this answer helpful" wherever the information provided helps you, this can be beneficial to other community members.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.