Running
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"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
)
in vscode
pyenv shell 3.9.12
Requirement already satisfied: azure-functions in ./.venv/lib/python3.9/site-packages (from -r requirements.txt (line 5)) (1.12.0)
WARNING: You are using pip version 21.2.4; however, version 22.3 is available.
You should consider upgrading via the '/Users/deniz/Library/CloudStorage/OneDrive-DualCitizen/Dev/2ndfunction/.venv/bin/python -m pip install --upgrade pip' command.
* Terminal will be reused by tasks, press any key to close it.
* Executing task: . .venv/bin/activate && func host start
Found Python version 3.9.10 (python3).
Azure Functions Core Tools
Core Tools Version: 4.0.4829 Commit hash: N/A (64-bit)
Function Runtime Version: 4.11.2.19273
[2022-10-23T09:38:17.290Z] Failed to initialize worker provider for: /opt/homebrew/Cellar/azure-functions-core-tools@4/4.0.4829/workers/python
[2022-10-23T09:38:17.290Z] Microsoft.Azure.WebJobs.Script: Architecture Arm64 is not supported for language python.
[2022-10-23T09:38:17.818Z] Failed to initialize worker provider for: /opt/homebrew/Cellar/azure-functions-core-tools@4/4.0.4829/workers/python
[2022-10-23T09:38:17.818Z] Microsoft.Azure.WebJobs.Script: Architecture Arm64 is not supported for language python.
[2022-10-23T09:38:17.957Z] A host error has occurred during startup operation '29ac434c-0276-4c0b-a85f-c9e4863577dc'.
[2022-10-23T09:38:17.957Z] Microsoft.Azure.WebJobs.Script: Did not find functions with language [python].
[2022-10-23T09:38:17.964Z] Failed to stop host instance '3d492f60-0fd3-48dd-bce0-d7cc99da71c8'.
[2022-10-23T09:38:17.964Z] Microsoft.Azure.WebJobs.Host: The host has not yet started.
Value cannot be null. (Parameter 'provider')
[2022-10-23T09:38:17.986Z] A host error has occurred during startup operation '1327f3e2-25e9-4318-bfea-0bac013aff02'.
[2022-10-23T09:38:17.986Z] Microsoft.Extensions.DependencyInjection: Cannot access a disposed object.
[2022-10-23T09:38:17.986Z] Object name: 'IServiceProvider'.
* Terminal will be reused by tasks, press any key to close it.
I tried a bunch of things incl:
- Create a conda environment with supported python version
- Go to the root directory of the project, Remove .venv folder
- Activate the newly created conda environment
- Create new virtual environment using
python3 -m venv .venv/
I also tried to apply the Rosetta fix as outlined here How to run the Homebrew installer under Rosetta 2 on M1 Macbook
but wasn't successfull. How can I fix this?