Search code examples
pythonpython-requestsazure-functionsazure-application-insightspython-module

Requests Module not found in python, after deploying to Azure function


Is there any reason why things work all fine in Consumption plan and won't work at all in Premium plan ?

This has me mad, code below, in consumption plan works as expected

_*

Import requests

Blah blah blah blah I do with requests

_*

Same thing breaks when deployed in premium plan, and says Requests module not found

Why God ?

I tried checking requirements.txt & versions, SDK and everything, only thing differing is plan.

Why this shouldn't frustrate when big organization like microsoft does this to their loyal customer base ? With huge following

Please help


Solution

  • This is my code:

    import logging
    
    import azure.functions as func
    import requests
    
    
    def main(req: func.HttpRequest) -> func.HttpResponse:
    
        return func.HttpResponse(
                "This is a test.",
                status_code=200
        )
    

    And this is the requirements.txt on my side:

    # DO NOT include azure-functions-worker in this file
    # The Python Worker is managed by Azure Functions platform
    # Manually managing azure-functions-worker may cause unexpected issues
    
    azure-functions
    requests
    

    This is the structure of my function app:

    enter image description here

    The function app on azure is based on premium plan:

    enter image description here

    And it works fine on my side:

    enter image description here

    Please check the differences between you and me. Or maybe the problem on your side is temporary.