func new "HTTP trigger" incorrect case of ANONYMOUS for Python
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.
I should have included that it does not matter how you specify --authlevel, it will always be "Anonymous" in the generated code.
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?
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.
Thank you @robotdad for the detailed feedback. We will fix it soon.
@khkh-ms Is this something you are still tracking/working on or does it need to be reassigned?
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.
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.
why do I still get this error
@khkh-ms
I've gone ahead and submitted a fix for this now