Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python instructions for warmup function are erronous #62804

Closed
ncoder opened this issue Sep 17, 2020 · 10 comments
Closed

Python instructions for warmup function are erronous #62804

ncoder opened this issue Sep 17, 2020 · 10 comments

Comments

@ncoder
Copy link

ncoder commented Sep 17, 2020

Following these instructions leads to this error.

Exception: FunctionLoadError: cannot load the warmup function: the following parameters are declared in Python but not in function.json: {'warmupContext'}
Stack:   File "/usr/local/Cellar/azure-functions-core-tools@2/2.7.2883/workers/python/3.7/OSX/X64/azure_functions_worker/dispatcher.py", line 269, in _handle__function_load_request
    function_id, func, func_request.metadata)
  File "/usr/local/Cellar/azure-functions-core-tools@2/2.7.2883/workers/python/3.7/OSX/X64/azure_functions_worker/functions.py", line 114, in add_function
    f'the following parameters are declared in Python but '

It seems that the type specified in the function.json file does not match the annotation on the snippet.

I don't know what the right answer is, but I've managed to seemingly continue here by stripping the type info on the function.

Further feedback, while you're in there. The documentation states that the warmup function must be called "warmup" (case insensitive); I think this is pretty clear in C#, but a little less clear with python. (I understood that i need to make a module/folder called "warmup")


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

@MayankBargali-MSFT
Copy link
Contributor

@ncoder Thank you for your feedback! We will review and update as appropriate.

@MayankBargali-MSFT
Copy link
Contributor

@ncoder For the exception can you please verify if your function have name "warmupContext" for your warmup trigger function and function.json as below. As per the error message the name is define in function.json doesn't match what you have define. I have tested it at my end and couldn't observe the same behaviour.

def main(warmupContext: func.Context)

@ncoder
Copy link
Author

ncoder commented Sep 22, 2020

My apologies. I pasted an error message from a run of something else I had tried. I changed my code as above (and as documented) and saw again the original error that I wanted to bring to your attention.

Worker failed to function id 081eef2a-1db2-43c4-98a1-8a58ec83b845.
Result: Failure
Exception: FunctionLoadError: cannot load the warmup function: type of warmupContext binding in function.json "warmupTrigger" does not match its Python annotation "Context"
Stack:   File "/usr/local/Cellar/azure-functions-core-tools@2/2.7.2883/workers/python/3.7/OSX/X64/azure_functions_worker/dispatcher.py", line 269, in _handle__function_load_request
    function_id, func, func_request.metadata)
  File "/usr/local/Cellar/azure-functions-core-tools@2/2.7.2883/workers/python/3.7/OSX/X64/azure_functions_worker/functions.py", line 219, in add_function
    f'type of {param.name} binding in function.json '

this is from simply running "func start" from the command line

PYTHONPATH=`pwd` func start

To recap, of relevance here,i have:
warmup/azfwarmup.py:

import logging
import azure.functions as func


def main(warmupContext : func.Context) -> None:
    logging.info("WARMUP START")
    logging.info("WARMUP COMPLETE")

warmup/function.json

{
    "scriptFile": "azfwarmup.py",
    "bindings": [
        {
            "type": "warmupTrigger",
            "direction": "in",
            "name": "warmupContext"
        }
    ]
}

@ncoder
Copy link
Author

ncoder commented Sep 22, 2020

This may be of importance. I'm running on a mac with Python 3.7.9.
I can pull any other relevant machine configuration information you request.

@MayankBargali-MSFT
Copy link
Contributor

@ncoder Thanks for your response. I was able to repro the issue at my local machine and have reached out to my team. Will be updating this thread once I heard back from my team.

@MayankBargali-MSFT
Copy link
Contributor

MayankBargali-MSFT commented Oct 5, 2020

@ncoder Apology for the delay. I got confirmation from the product team that the warmup trigger is only available to apps running on the Premium plan. The same is mentioned in the document. You can test it premium plan and if you still facing the issue you can always reach out to azure support. Please let me know if you have any concerns.

@ncoder
Copy link
Author

ncoder commented Oct 5, 2020 via email

@MayankBargali-MSFT
Copy link
Contributor

@ncoder We will now proceed to close this thread. If there is any issue testing the premium plan feel free to open an azure support ticket or post your issue on Microsoft Q&A

@mhux2000
Copy link

I was also running into this issue on a Premium plan that is. It's a type error so my easy dirty fix was to remove the type definition altogether. Works like a charm.

import logging
import azure.functions as func


def main(warmupContext) -> None:
    logging.info("WARMUP START")
    logging.info("WARMUP COMPLETE")

@empowerNate
Copy link

empowerNate commented Mar 1, 2024

It seems this is still an issue?

Edit: can confirm, still an issue as of 2024-03-20.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants