How to develop python azure function my Mac with chip Apple M1 Pro

Brian Huimin Kang (US) 25 Reputation points
2023-06-13T08:06:31.4333333+00:00

Develop Environment: Mac with chip Apple M1 Pro

OS Version: Ventura 13.4

Tool: VScode

Is there a way for me to develop the python azure function locally ? A tutorial is best. thanks in advance.

How to fix the following issue:

[2023-06-14T02:43:00.884Z] Failed to initialize worker provider for: /usr/local/lib/node_modules/azure-functions-core-tools/bin/workers/python

[2023-06-14T02:43:00.885Z] Microsoft.Azure.WebJobs.Script: Architecture Arm64 is not supported for language python.

[2023-06-14T02:43:02.735Z] Failed to initialize worker provider for: /usr/local/lib/node_modules/azure-functions-core-tools/bin/workers/python

[2023-06-14T02:43:02.736Z] Microsoft.Azure.WebJobs.Script: Architecture Arm64 is not supported for language python.

[2023-06-14T02:43:02.941Z] A host error has occurred during startup operation '44a2260d-b406-4d5e-ba5e-ef0aebad8aa2'.

[2023-06-14T02:43:02.941Z] Microsoft.Azure.WebJobs.Script: Did not find functions with language [python].

[2023-06-14T02:43:02.947Z] Failed to stop host instance '86e7a873-6c19-45b4-901b-214d4a28a97d'.

[2023-06-14T02:43:02.947Z] Microsoft.Azure.WebJobs.Host: The host has not yet started.

Value cannot be null. (Parameter 'provider')

[2023-06-14T02:43:02.995Z] A host error has occurred during startup operation '89398787-ab21-4620-8cd5-f438d27b88b1'.

[2023-06-14T02:43:02.995Z] Microsoft.Extensions.DependencyInjection: Cannot access a disposed object.

[2023-06-14T02:43:02.995Z] Object name: 'IServiceProvider'.

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
{count} votes

Answer accepted by question author
  1. MayankBargali-MSFT 70,981 Reputation points Moderator
    2023-06-14T06:37:05.36+00:00
    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Brian Huimin Kang (US) 25 Reputation points
    2023-06-28T01:44:48.6966667+00:00

    Thanks for all your answer. Sorry for late reply

    I find a way to work out this issue. It might only work for my case. But for others, it might give you some insight.

    Steps:

    1. install miniforge3 and then create a x86_64 environment
    2. install azure-functions-core-tools with npm
    3. create the .venv environment by leveraging the x86_64 env
    4. update /usr/local/lib/node_modules/azure-functions-core-tools/bin/workers/python/worker.config.json :
        "defaultWorkerPath":"%FUNCTIONS_WORKER_RUNTIME_VERSION%/{os}/X64/worker.py",
      
      1. when launch your python azure function, please activate .venv env first .

    References:

    https://towardsdatascience.com/python-conda-environments-for-both-arm64-and-x86-64-on-m1-apple-silicon-147b943ffa55

    https://github.com/conda-forge/miniforge

    https://www.dataquest.io/blog/a-complete-guide-to-python-virtual-environments/

    https://medium.com/@andreas.katzian/running-python-azure-function-locally-on-an-m1-18dae7128ac8

    http://issamben.com/running-python-azure-function-locally-on-an-m1-m2/

    1 person found this answer helpful.

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.