pythonvisual-studio-codeazure-functionstimer-trigger

Azure Functions Python V2 Timer Trigger Does Not Deploy but Status Success in VSCode


I am deploying a very basic Azure Functions App to demonstrate a few key features.

I have two functions, one demonstrating an HTTP Trigger and the other demonstrating a Timer Trigger. Both run perfectly on local instance.

import azure.functions as func
import os
import datetime
import logging

app = func.FunctionApp()

@app.function_name(name="HttpTrigger1")
@app.route(route="keyvaulttest")
def test_function(req: func.HttpRequest) -> func.HttpResponse:
    logging.info('Python HTTP trigger function processed a request.')
    utc_timestamp = datetime.datetime.utcnow().replace(
        tzinfo=datetime.timezone.utc).isoformat()

    test_phrase = os.getenv("TestEnvFromKeyVault")

    logging.info(f'TestEnvFromKeyVault: {test_phrase}')
    logging.info('Python HTTP trigger function ran at %s', utc_timestamp)
 
    return func.HttpResponse(
        test_phrase,
        status_code=200
    )

@app.function_name(name="TestTimer")
@app.schedule(schedule="0 */5 * * * *", arg_name="test_timer", use_monitor=False) 
def test_function(test_timer: func.TimerRequest) -> None:
    utc_timestamp = datetime.datetime.utcnow().replace(
        tzinfo=datetime.timezone.utc).isoformat()

    test = os.getenv("TestEnvFromKeyVault")

    if test_timer.past_due:
        logging.info('The timer is past due!')

    logging.info(f'TestEnvFromKeyVault: {test}')
    logging.info('Python timer trigger function ran at %s', utc_timestamp)

When I attempt to deploy using the VSCode Azure Function extension command "Azure Functions: Deploy to FunctionApp" it says it deployed successfully. My HTTP Trigger function is deployed and works, but my Timer Trigger function is not deployed.

12:13:48 PM testapp: Deployment successful. deployer = ms-azuretools-vscode deploymentPath = Functions App ZipDeploy. Extract zip. Remote build.

enter image description here


Solution

  • I did what the above solution did (including the configurations) and still found myself in the same issue described by OP. After getting on a call w Microsoft support and everything, ultimately what did it was deleting the line :

    @app.function_name(name="HttpTrigger1")
    

    ...apparently in v2 the function name is read from def test_function like any other function would and the above line is causing interference reading the function when uploaded.