Using blobTrigger with Azurite crashes function host

2.2k Views Asked by At

I'm running into a problem with a Azure blob triggered function crashing the function host. It seems to be an issue with the storage connection string or how I'm using Azurite. Other timer or HTTP trigger functions I'm working on work fine with the "UseDevelopmentStorage=true" setting and the Azurite blob service running.

I'm rather stumped as to what the issue could be with getting a blob trigger function to work in my dev environment using the Azurite storage emulator.

Any suggests about what I'm missing or where to look futher?

This is the error message I get about 10 to 20 seconds after the function host starts:

An unhandled exception has occurred. Host is shutting down. Microsoft.WindowsAzure.Storage: No connection could be made because the target machine actively refused it. System.Net.Http: No connection could be made because the target machine actively refused it. System.Private.CoreLib: No connection could be made because the target machine actively refused it.

The function.json file for the blob trigger function looks like this:

{
  "scriptFile": "__init__.py",
  "bindings": [
    {
      "name": "myblob",
      "type": "blobTrigger",
      "direction": "in",
      "path": "outcontainer/{name}",
      "connection": "AzureWebJobsStorage"
    }
  ]
}

The local.settings.json file has this:

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

This is the output from console with the --verbose switch enabled:

[9/23/2020 6:28:36 PM] Job host started
Functions:

        BlobTrigger1: blobTrigger

Hosting environment: Production
Content root path: C:\sources\AzureBlobTriggerTest
Now listening on: http://0.0.0.0:7071
Application started. Press Ctrl+C to shut down.
[9/23/2020 6:28:37 PM] LanguageWorkerConsoleLog INFO: Starting Azure Functions Python Worker.
[9/23/2020 6:28:37 PM] LanguageWorkerConsoleLog INFO: Worker ID: d4160c17-a9f0-461d-af04-18623c45a51b, Request ID: fdf8841e-8564-4f4e-a983-91553451cd9d, Host Address: 127.0.0.1:51168
[9/23/2020 6:28:37 PM] LanguageWorkerConsoleLog INFO: Successfully opened gRPC channel to 127.0.0.1:51168
[9/23/2020 6:28:37 PM] LanguageWorkerConsoleLog INFO: Detaching console logging.
[9/23/2020 6:28:37 PM] Switched to gRPC logging.
[9/23/2020 6:28:37 PM] Received WorkerInitRequest, request ID fdf8841e-8564-4f4e-a983-91553451cd9d
[9/23/2020 6:28:37 PM] Worker process started and initialized.
[9/23/2020 6:28:37 PM] Received FunctionLoadRequest, request ID: fdf8841e-8564-4f4e-a983-91553451cd9d, function ID: dc522140-aa0a-453b-8767-4aedf88435e4
[9/23/2020 6:28:37 PM] Successfully processed FunctionLoadRequest, request ID: fdf8841e-8564-4f4e-a983-91553451cd9d, function ID: dc522140-aa0a-453b-8767-4aedf88435e4
[9/23/2020 6:28:41 PM] Host lock lease acquired by instance ID '0000000000000000000000002B956994'.
[9/23/2020 6:29:09 PM] An unhandled exception has occurred. Host is shutting down.
[9/23/2020 6:29:09 PM] Microsoft.WindowsAzure.Storage: No connection could be made because the target machine actively refused it. System.Net.Http: No connection could be made because the target machine actively refused it. System.Private.CoreLib: No connection could be made because the target machine actively refused it.
[9/23/2020 6:29:09 PM] Stopping host...
[9/23/2020 6:29:09 PM] Stopping JobHost
[9/23/2020 6:29:09 PM] Stopping the listener 'Microsoft.Azure.WebJobs.Host.Listeners.CompositeListener' for function 'BlobTrigger1'
[9/23/2020 6:29:09 PM] Stopped the listener 'Microsoft.Azure.WebJobs.Host.Listeners.CompositeListener' for function 'BlobTrigger1'
[9/23/2020 6:29:09 PM] Job host stopped
[9/23/2020 6:29:09 PM] Host shutdown completed.
2

There are 2 best solutions below

0
On

To run a Node blobTrigger locally you need to:

  1. Make sure you are running Node 8 or 10. I run 10.14.1

  2. Change local.settings.json:

"AzureWebJobsStorage": "UseDevelopmentStorage=true"

  1. Run azurite with all services. Not only BlobStorage.
0
On

Looks like I found what I was doing wrong. The documentation says, "The Azure Blob storage trigger requires a general-purpose storage account."

I was only starting the Azurite blob service. Starting the whole thing gets it working.

VSCode command palette