azure-functions-core-tools icon indicating copy to clipboard operation
azure-functions-core-tools copied to clipboard

func new "HTTP trigger" incorrect case of ANONYMOUS for Python

Open robotdad opened this issue 1 year ago • 5 comments

The code generated by the call below is incorrect for both v1 and v2 for Python. func new --name HttpExample --template "HTTP trigger" --authlevel anonymous

This will generate the following line in function_app.py. @app.route(route="HttpExample", auth_level=func.AuthLevel.Anonymous) This should be: @app.route(route="HttpExample", auth_level=func.AuthLevel.ANONYMOUS)

This breaks most getting started samples on mslearn for Python out of the box.

robotdad avatar Apr 26 '24 17:04 robotdad

I should have included that it does not matter how you specify --authlevel, it will always be "Anonymous" in the generated code.

robotdad avatar Apr 26 '24 20:04 robotdad

Hi @robotdad I was able to repro the issue described with the string showing up in lowercase instead of all upper case- but not your second comment that the auth level always shows as Anonymous regardless of the indicated auth level. Can you please confirm the version of Core Tools you are using?

shreyabatra4 avatar Apr 29 '24 19:04 shreyabatra4

func --version 4.0.5611

My comment was unclear, apologies. I meant that the casing of what I pass as the value to specify anonymous does not impact the code generation, either --authlevel ANONYMOUS or --authlevel anonymous generate the same code that uses mixed case Anonymous.

If I don't specify --authlevel then func tools prompts to select a value and when choosing ANONYMOUS the generated code is correct.

I've not tried the other auth levels.

robotdad avatar Apr 29 '24 22:04 robotdad

Thank you @robotdad for the detailed feedback. We will fix it soon.

khkh-ms avatar May 14 '24 19:05 khkh-ms

@khkh-ms Is this something you are still tracking/working on or does it need to be reassigned?

satvu avatar Jul 10 '24 20:07 satvu

Same issue. Functions CLI is doing AuthorizationLevel?.ToString() for the AuthorizationLevel enum where enum names are in pascal case, and Enum.ToString() will map to this same casing.

maskati avatar Jan 27 '25 07:01 maskati

As someone who's new to Python/core tools and following this tutorial on Microsoft Learn, this bug took way longer than it should have to figure out on my own.

I realize there are probably a million things with high urgency, but if I hadn't needed to learn this for work I may have changed direction... how many students/beginners/hobbyists have completely abandoned the tutorial because they're getting errors and can't proceed when following documentation that's designed to help them get started?

I tried to figure out where to make the change in case this is something I could take on to help get the fix expedited, but again being new to Python I got lost and fortunately found this issue before creating a duplicate.

manningli avatar Feb 04 '25 21:02 manningli

why do I still get this error

amadou-6e avatar Feb 18 '25 13:02 amadou-6e

@khkh-ms

amadou-6e avatar Feb 18 '25 13:02 amadou-6e

I've gone ahead and submitted a fix for this now

dirkesquire avatar Apr 22 '25 05:04 dirkesquire