Skip to content
Advertisement

“ModuleNotFoundError” with Azure function Apps using Python

I keep getting the error

ModuleNotFoundError: No module named ‘azure’

for line 4 where I import azure.functions as func Below is the code for my init file that has been designed using this tutorial

import logging
import azure.functions as func

def main(req: func.HttpRequest) -> func.HttpResponse:
    logging.info('Python HTTP trigger function processed a request.')

    name = req.params.get('name')
    if not name:
        try:
            req_body = req.get_json()
        except ValueError:
            pass
        else:
            name = req_body.get('name')

    if name:
        return func.HttpResponse(f"Hellod {name}!")

    else:
        return func.HttpResponse(
             "Please pass a name on the query string or in the request body",
             status_code=400
        )

Any help with this would be much appriciated!

Advertisement

Answer

Did you pip installed the library in your python environment?

pip install azure
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement