Import pinecone -> Worker failed to load function: 'createPineConeIndex' with functionId: 'de03aa8b-f597-4ee3-a816-eb54685435b5

I want to create the indexing functionality as an Azure Function to be able to schedule it via cron trigger or execute it ondemand via http triggers.

However after installing the client, even import pinecone breaks the environment.

I am not sure if this is related to pinecone or azure core functions runtime

I have reported this also in Azure Github repo for core tools

@levalencia

Hello!

I tested it with a minimal configuration, and it worked fine with both the Python Programming Model V2 and V1.

Here are the details of the environment I tested on:

Azure Functions Core Tools

  • Core Tools Version: 4.0.5198 Commit hash: N/A (64-bit)
  • Function Runtime Version: 4.21.1.20667
  • Python version 3.10.11 (py)

requirements.txt:

azure-functions
pinecone-client

local.settings.json:

{
  "IsEncrypted": false,
  "Values": {
    "FUNCTIONS_WORKER_RUNTIME": "python",
    "AzureWebJobsStorage": "UseDevelopmentStorage=true",
    "AzureWebJobsFeatureFlags": "EnableWorkerIndexing"
  }
}

function_app.py:

import azure.functions as func
import pinecone

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

@app.route(route="HttpTrigger")
def HttpTrigger(req: func.HttpRequest) -> func.HttpResponse:    
    pinecone.init(
        api_key="xxxxxx",
        environment="xxxxxx"
    )
    
    indexName = req.params.get('indexName')

    if indexName:
        if indexName not in pinecone.list_indexes():
            # we create a new index
            pinecone.create_index(
                name=indexName,
                metric='dotproduct',
                dimension=1536  # 1536 dim of text-embedding-ada-002
            )
            return func.HttpResponse(f"Index: {indexName}  created. This HTTP triggered function executed successfully.",status_code=200)
        else:
            return func.HttpResponse(f"Index: {indexName} already exists. This HTTP triggered function executed successfully.",status_code=200)
    else:
        return func.HttpResponse(f"Please pass a indexName on the query string or in the request body")

It seems you have several packages in use. To identify the issue, you could try adding the packages incrementally to see if any particular package is causing the problem.

Are you using conda or venv?

@levalencia

Yes, I am using venv. (venv was automatically generated by the tool.)
The environment I tested can be set up using the Azure Functions auto-generation feature in VS Code.
All I did was click a button and made a few modifications to the generated code.

thanks I started from scratch and it works, I think the issue was related to Conda or when selecting the Python interpreter

1 Like