azure-functions-python-worker: [BUG] Azure function works locally but not when deployed

Investigative information

Please provide the following:
  • Timestamp: 2023-07-20T14:31:57Z
  • Function App name: xxxx
  • Function name(s) (as appropriate):
  • Core Tools version:C
  • Core Tools Version: 4.0.5198 Commit hash: N/A (64-bit) Function Runtime Version: 4.21.1.20667

Repro steps

Provide the steps required to reproduce the problem:

I developed an Azure Function iN VS code and it works locally, I can test it in Postman or in the browser.

Just a small example of one of the functions:

@app.route(route="CreatePineConeIndex")
def CreatePineConeIndex(req: func.HttpRequest) -> func.HttpResponse:
    """Create a Pinecone index.

    Args:
        req (func.HttpRequest): The HTTP request object.

    Returns:
        func.HttpResponse: The HTTP response object.
    """
    try:
        req_body = req.get_json()
        api_key = req_body.get('api_key')
        environment = req_body.get('environment')
        index_name = req_body.get('indexName')
        dimensions = req_body.get('dimensions', 1536)
        metric = req_body.get('metric', 'dotproduct')

        client = PineconeClient(api_key=api_key, environment=environment)
        client.CreateIndex(index_name, dimension=dimensions, metric=metric)

        return func.HttpResponse("Index Created", status_code=200)
    except Exception as e:
        return func.HttpResponse(f"Could not create Pinecone Index. {str(e)}", status_code=500)

I have tested the deploy from VS Code or via Azure Devops pipelines, deployment works without any errors

However the Azure Function url /api/CreatePineConeIndex shows as 404 however localhost/api/CreatePineConeIndex works

I already did this: https://learn.microsoft.com/en-us/azure/azure-functions/recover-python-functions?tabs=vscode%2Cbash&pivots=python-mode-decorators#issue-with-deployment

image

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 23 (2 by maintainers)

Most upvoted comments

I added some logging and couldnt find any exception, however in the traces I can see:

No job functions found. Try making your job classes and methods public.

oh sorry, I misread 😦

I had to set the log level to debug in the host.json

{
  "version": "2.0",
     "logging": {
        "fileLoggingMode": "debugOnly",
        "logLevel": {
          "default": "Trace",
          "Host.Results": "Trace",
          "Function": "Trace",
          "Host.Aggregator": "Trace"
        },
        "applicationInsights": {
            "samplingSettings": {
              "isEnabled": true,
              "maxTelemetryItemsPerSecond" : 20,
              "evaluationInterval": "01:00:00",
              "initialSamplingPercentage": 100.0,
              "samplingPercentageIncreaseTimeout" : "00:00:01",
              "samplingPercentageDecreaseTimeout" : "00:00:01",
              "minSamplingPercentage": 0.1,
              "maxSamplingPercentage": 100.0,
              "movingAverageRatio": 1.0,
              "excludedTypes" : "Dependency;Event",
              "includedTypes" : "PageView;Trace"
            },
            "enableLiveMetrics": true,
            "enableDependencyTracking": true,
            "enablePerformanceCountersCollection": true,
            "httpAutoCollectionOptions": {
                "enableHttpTriggerExtendedInfoCollection": true,
                "enableW3CDistributedTracing": true,
                "enableResponseHeaderInjection": true
            },
            "snapshotConfiguration": {
                "agentEndpoint": null,
                "captureSnapshotMemoryWeight": 0.5,
                "failedRequestLimit": 3,
                "handleUntrackedExceptions": true,
                "isEnabled": true,
                "isEnabledInDeveloperMode": false,
                "isEnabledWhenProfiling": true,
                "isExceptionSnappointsEnabled": false,
                "isLowPrioritySnapshotUploader": true,
                "maximumCollectionPlanSize": 50,
                "maximumSnapshotsRequired": 3,
                "problemCounterResetInterval": "24:00:00",
                "provideAnonymousTelemetry": true,
                "reconnectInterval": "00:15:00",
                "shadowCopyFolder": null,
                "shareUploaderProcess": true,
                "snapshotInLowPriorityThread": true,
                "snapshotsPerDayLimit": 30,
                "snapshotsPerTenMinutesLimit": 1,
                "tempFolder": null,
                "thresholdForSnapshotting": 1,
                "uploaderProxy": null
            }
        }
    },
    "extensionBundle": {
        "id": "Microsoft.Azure.Functions.ExtensionBundle",
        "version": "[3.3.0, 4.0.0)"
    }
}

and then in the application insights a simple

traces
| where cloud_RoleName contains "<insertfunctionappname>"

pls share your requirement .txt file

seems issue in pine core client lib will update you on this as soon as possible. Thanks