I already have a storage account in same region in same resourcegroup
Not able to deploy function in function app
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
2 answers
Sort by: Most helpful
-
-
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:
Output:
Azure Portal:
Locally:
Also refer Microsoft docs on Creating and Deploying Functions.
You will find Storage Account :
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.