Not able to deploy function in function app

Ritwik Math 20 Reputation points
2025-02-19T22:49:03.4766667+00:00

I can run the function in local. When trying to deploy the function app. the message is successful but my functions are not visible in portal.

This is my fucntion_app.py

import azure.functions as func
import logging

app = func.FunctionApp(http_auth_level=func.AuthLevel.ANONYMOUS)

@app.route(route="http_trigger")
def http_trigger(req: func.HttpRequest) -> func.HttpResponse:
    logging.info('Python HTTP trigger function processed a request.')

    name = req.params.get('name')
    if not name:
        try:
            req_body = req.get_json()
        except ValueError:
            pass
        else:
            name = req_body.get('name')

    if name:
        return func.HttpResponse(f"Hello, {name}. This HTTP triggered function executed successfully.")
    else:
        return func.HttpResponse(
             "This HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response.",
             status_code=200
        )

@app.timer_trigger(schedule="0 * * * * *", arg_name="myTimer", run_on_startup=False,
              use_monitor=False) 
def timer_trigger(myTimer: func.TimerRequest) -> None:
    
    if myTimer.past_due:
        logging.info('The timer is past due!')

    logging.info('Python timer trigger function executed.')

host.json

{
  "version": "2.0",
  "logging": {
    "applicationInsights": {
      "samplingSettings": {
        "isEnabled": true,
        "excludedTypes": "Request"
      }
    }
  },
  "extensionBundle": {
    "id": "Microsoft.Azure.Functions.ExtensionBundle",
    "version": "[4.*, 5.0.0)"
  }
}
Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,929 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Ritwik Math 20 Reputation points
    2025-02-19T22:49:59.3233333+00:00

    I already have a storage account in same region in same resourcegroup

    0 comments No comments

  2. RithwikBojja 3,055 Reputation points Microsoft External Staff Moderator
    2025-02-24T11:41:38.2566667+00:00

    Hi @Ritwik Math,

    Below approach worked and I am able to see my functions:

    function_app.py:

    
        import azure.functions as func
    
        import logging as rilg
    
        
    
        choapp = func.FunctionApp(http_auth_level=func.AuthLevel.ANONYMOUS)
    
        
    
        @choapp.route(route="http_trigger")
    
        def http_trigger(req: func.HttpRequest) -> func.HttpResponse:
    
            rilg.info('Hello Rithwik')
    
            return func.HttpResponse("Hello",status_code=200)
    
        
    
        @choapp.schedule(schedule="*/30 * * * * *", arg_name="myTimer", run_on_startup=True,use_monitor=False) 
    
        def timer_trigger(myTimer: func.TimerRequest) -> None:
    
            rilg.info('Hello Rithwik')
    
    

    local.settings.json:

    
        {
    
          "IsEncrypted": false,
    
          "Values": {
    
            "AzureWebJobsStorage": "",
    
            "FUNCTIONS_WORKER_RUNTIME": "python",
    
            "AzureWebJobsFeatureFlags": "EnableWorkerIndexing"
    
          }
    
        }
    
    

    requirements.txt:

    azure-functions

    host.json:

    
    {
    
          "version": "2.0",
    
          "logging": {
    
            "applicationInsights": {
    
              "samplingSettings": {
    
                "isEnabled": true,
    
                "excludedTypes": "Request"
    
              }
    
            }
    
          },
    
          "extensionBundle": {
    
            "id": "Microsoft.Azure.Functions.ExtensionBundle",
    
            "version": "[4.*, 5.0.0)"
    
          }
    
        }
    
    

    Structure:

    
        NEW_FOLDER2/              
    
        │── __pycache__/         
    
        │── .venv/               
    
        │── .vscode/             
    
        │── .funcignore          
    
        │── .gitignore           
    
        │── function_app.py      
    
        │── host.json            
    
        │── local.settings.json  
    
        │── requirements.txt  
    
    

    Deployed to Azure:

    enter image description here

    enter image description here

    Output:

    Azure Portal:

    enter image description here

    Locally:

    enter image description here

    Also refer Microsoft docs on Creating and Deploying Functions.

    You will find Storage Account :

    enter image description here

    Hope this helps.

    If the answer is helpful, please click Accept Answer and kindly upvote it. If you have any further questions about this answer, please click Comment.


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.