Error with Azure Functions in Python: “WorkerConfig for runtime: python not found” and “Value cannot be null (Parameter ‘provider’) with python 3.11.9

I’m trying to set up an Azure Function in Python, but I’m encountering errors when running the function. Below is my function code:

import azure.functions as func
import logging

app = func.FunctionApp(http_auth_level=func.AuthLevel.ANONYMOUS)

@app.route(route="APIPreguntaleia")
def APIPreguntaleia(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"Hello, {name}. This HTTP triggered function executed successfully.")
    else:
        return func.HttpResponse(
             "This HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response.",
             status_code=200
        )

When I run the function, I get the following console error:

Executing task: .venvScriptspython -m pip install -r requirements.txt 

Requirement already satisfied: azure-functions in r:fast-api.venvlibsite-packages (from -r requirements.txt (line 5)) (1.19.0)
 *  Terminal will be reused by tasks, press any key to close it. 

 *  Executing task: .venvScriptsactivate ; func host start 

Found Python version 3.11.9 (py).

Azure Functions Core Tools
Core Tools Version:       4.0.5801 Commit hash: N/A +5ac2f09758b98257e728dd1b5576ce5ea9ef68ff (64-bit)
Function Runtime Version: 4.34.1.22669

[2024-05-30T19:29:34.890Z] A host error has occurred during startup operation '95a1dbe5-8264-4a29-b39a-5a6dc58447df'.
[2024-05-30T19:29:34.893Z] Microsoft.Azure.WebJobs.Script: WorkerConfig for runtime: python not found.
[2024-05-30T19:29:34.903Z] Failed to stop host instance '96a67c8f-f7a7-45fa-83c3-be938325ae8c'.
[2024-05-30T19:29:34.907Z] Microsoft.Azure.WebJobs.Host: The host has not yet started.
Value cannot be null. (Parameter 'provider')
[2024-05-30T19:29:34.915Z] Host startup operation has been canceled

 *  The terminal process "C:Program FilesPowerShell7pwsh.exe -Command .venvScriptsactivate ; func host start" terminated with exit code: 1. 
 *  Terminal will be reused by tasks, press any key to close it. 

I tried installing the azure-functions-worker package, but encountered another error:

PS R:Fast-API> pip install azure-functions-worker
Collecting azure-functions-worker
  Using cached azure_functions_worker-1.1.9-py3-none-any.whl.metadata (7.7 kB)
Collecting grpcio~=1.33.1 (from azure-functions-worker)
  Using cached grpcio-1.33.2.tar.gz (20.9 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Installing backend dependencies ... done
  Preparing metadata (pyproject.toml) ... done
Collecting grpcio-tools~=1.33.1 (from azure-functions-worker)
  Using cached grpcio-tools-1.33.2.tar.gz (2.1 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Installing backend dependencies ... done
  Preparing metadata (pyproject.toml) ... done
Collecting six>=1.5.2 (from grpcio~=1.33.1->azure-functions-worker)
  Using cached six-1.16.0-py2.py3-none-any.whl.metadata (1.8 kB)
Collecting protobuf<4.0dev,>=3.5.0.post1 (from grpcio-tools~=1.33.1->azure-functions-worker)
  Using cached protobuf-3.20.3-py2.py3-none-any.whl.metadata (720 bytes)
Using cached azure_functions_worker-1.1.9-py3-none-any.whl (54 kB)
Using cached protobuf-3.20.3-py2.py3-none-any.whl (162 kB)
Using cached six-1.16.0-py2.py3-none-any.whl (11 kB)
Building wheels for collected packages: grpcio, grpcio-tools
  Building wheel for grpcio (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Building wheel for grpcio (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [80 lines of output]
      ...
      error: [WinError 2] El sistema no puede encontrar el archivo especificado
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for grpcio
  Building wheel for grpcio-tools (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Building wheel for grpcio-tools (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [69 lines of output]
      ...
      grpc_tools_protoc_compiler.cpp(394): fatal error C1083: No se puede abrir el archivo incluir: 'longintrepr.h': No such file or directory
      error: command 'C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.39.33519\bin\HostX86\x64\cl.exe' failed with exit code 2
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for grpcio-tools
Failed to build grpcio grpcio-tools
ERROR: Could not build wheels for grpcio, grpcio-tools, which is required to install pyproject.toml-based projects

Environment details:

Python version: 3.11.9
Azure Functions Core Tools version: 4.0.5801
I’ve tried several solutions but nothing seems to work. How can I fix this issue?

Thanks for the help.

New contributor

Sebastián Romero is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật