0

I am unable to make successful deployment of Azure Function when I require torch for my service. Earlier, I could deploy if I comment-out torch from requirements.txt file, which is explained after the following Update section:

UPDATE: I partially solved it. The problem is with dependencies listed in requirements.txt file. I am using spacy and downloading 'en_core_web_sm' model. So I added following line in requirements.txt file and it was able to load en_core_web_sm as well:

https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-3.7.1/en_core_web_sm-3.7.1.tar.gz

Now, the basic functionality is working. But for one of a service I need torch. If I comment-out this service and torch from requirements.txt file, then the deployment is successful and I can access endpoints. As soon as I try to install torch, I get deployment failed with error in Output: enter image description here

I am installing torch by having this line in requirements.txt file:

torch==2.2.0 --index-url https://download.pytorch.org/whl/cpu

Question now: Does it have to do with size of torch package? (I am running function in an Azure App Service Plan with Pricing plan = Y1)

My app looks like this (one function shown here1) in function_app.py file:

@app.function_name(name='Tokenizer')
@app.route(route='tokenization')
def tokenization(req: func.HttpRequest) -> func.HttpResponse:
    if req.method=='POST':
        logging.info("Processing POST Request ... ")
        return _post_handler_tokenization(req)

    elif req.method == 'GET':
        logging.info("Processing GET Request ... ")
        return _get_handler_tokenization(req)

    return func.HttpResponse('[INFO] Service isnt ready', mimetype='text/plain', status_code=200)

I am able to send and get HTTP req/res locally as shown below: enter image description here

====NOTE====: The problem below was solved by commenting out torch (as discussed above) and providing correct spacy dependency in requirements.txt file!

Now when I try to deploy this function to Azure Function App, I am able to deploy it but the function doesn't apear on Azure, as shown below:

enter image description here

enter image description here

I restarted the Azure Function and tried again the deployment but the function is not accessible. In the output section I saw logs and I sense a problem. I was expecting it would detect http trigger URLs as I saw on sample azure function deployment, but I see this:

enter image description here

And I also tried to do deployment via terminal using this command:

func azure functionapp publish <Azure_Function_App_Name> --build remote

And the result on terminal was this:

enter image description here

But the function doesn't show up on Azure Function App. Can anyone help me where I am going wrong? Thanks

2
  • Are you on the correct deployment slot? Commented Mar 1, 2024 at 12:40
  • yes there is only 1 deployment slot and the name is correct! Commented Mar 1, 2024 at 12:42

1 Answer 1

0

Ah, the joys of deployment mysteries! Let's debug this like seasoned detectives, shall we? First off, ensure that your Azure Function App is set up correctly to route requests to this particular function. Check the function name and route settings in your Azure portal. If everything looks fine there, let's dive into the logs. Have you checked the Azure Function App logs for any errors or warnings? Sometimes, the clues are hidden in plain sight. Also, make sure that your function's dependencies are properly installed in the Azure environment. Missing dependencies can often lead to unexpected behavior. Keep investigating, and you'll crack this case in no time!

Sign up to request clarification or add additional context in comments.

3 Comments

1) I tested first step by deploying sample from Azure documentation (learn.microsoft.com/en-us/azure/azure-functions/…), it works and is accessible. 2) How can I do this "Check the function name and route settings in your Azure portal", do you mean on Azure Function App Service?
3) Logs on Azure Function App are empty and I guess that is because there is no Function deployed/accessible! Local deployment logs I posted in my question 4) Function dependencies, yes that is good point. I have created necessary env vars already. Necessary pkgs are in requirements.txt file
I partially solved the problem and updated my question. Can you review it? The problem was with dependencies and now only to deal with installation of torch! Thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.