azure-functions-host icon indicating copy to clipboard operation
azure-functions-host copied to clipboard

Timer Trigger arg_name cannot use snake case

Open williamhbell opened this issue 1 year ago • 6 comments

Investigative information

func --version
4.0.5530

Repro steps

Provide the steps required to reproduce the problem:
  • Create a new Azure function
func new --template "Timer Trigger" --name another_trigger
  • Change the generated code from
@app.timer_trigger(schedule="0 */5 * * * *", arg_name="myTimer", run_on_startup=True,
              use_monitor=False) 
def another_trigger(myTimer: func.TimerRequest) -> None:

to

@app.timer_trigger(schedule="0 */5 * * * *", arg_name="my_timer", run_on_startup=True,
              use_monitor=False) 
def another_trigger(my_timer: func.TimerRequest) -> None:
  • Run the function, which results in an error of the form:
The 'another_trigger' function is in error: The binding name my_timer is invalid. Please assign a valid name to the binding.

Expected behaviour

It should be possible to use a binding name that uses snake case, since this is the normal convention for Python programs.

Actual behaviour

The 'another_trigger' function is in error: The binding name my_timer is invalid. Please assign a valid name to the binding.

Known workarounds

Remove the _ character from the binding and variable name.

Contents of the requirements.txt file:

azure-functions==1.18.0

williamhbell avatar Feb 19 '24 20:02 williamhbell

Thanks for reporting will check and update.Thanks

bhagyshricompany avatar Feb 23 '24 11:02 bhagyshricompany

Hi @williamhbell pls have a look this is not supported.https://github.com/Azure/azure-functions-python-worker/issues/1174

bhagyshricompany avatar Feb 26 '24 15:02 bhagyshricompany

@bhagyshricompany thanks for spotting Azure/azure-functions-python-worker#1174. It appears to be the same bug. As mentioned in Azure/azure-functions-python-worker#1174, snake case is normally used for Python variables following PEP8 https://peps.python.org/pep-0008/#function-and-variable-names .

williamhbell avatar Feb 26 '24 16:02 williamhbell

yes but right now not have support.

bhagyshricompany avatar Feb 26 '24 17:02 bhagyshricompany

the validation is done in azure functions host at https://github.com/Azure/azure-functions-host/blob/1ed94659541864f111cc01f4db9480d64132140c/src/WebJobs.Script/Utility.cs#L60.

YunchuWang avatar Mar 08 '24 21:03 YunchuWang

Transferring to Azure Function Host to continue the discussion

YunchuWang avatar Mar 08 '24 23:03 YunchuWang