Blob trigger not waking up the docker container

80 Views Asked by At

I have two functions in my container: one with a blob trigger and another one with a HTTP trigger. Runtime version is 4.28.4.4:

Function container

The managed environment is "Consumption only".

Managed environment

When I add a blob to my storage, hours go by without the function being triggered.

Then I call the HTTP function (a simple function that just returns "hello") and all my pending blobs get processed.

When the blob finally triggers, it executes without errors:

Blob triggered

Bellow is my HTTP trigger code:

[FunctionName("SayHello")]
public static IActionResult Run(
    [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequest req,
    ILogger log)
{
    var message = "Hello!";
    return new OkObjectResult(message);
}

Blob trigger:

[FunctionName("ProcessJpegImage")]
public static async Task RunAsync(
    [BlobTrigger(Containers.JpgExportProcessing + "/{name}", Connection = "[REDACTED]")] Stream inputBlob,
    string name,
    IDictionary<string, string> metadata,
    ILogger log)
{
    // ... processing code
}

I have the container name in another class:

public static class Containers
{
    public const string JpgExportProcessing = "jpg-export-processing";
    // ... more containers
}

My host.json is the default:

{
    "version": "2.0",
    "logging": {
        "applicationInsights": {
            "samplingSettings": {
                "isEnabled": true,
                "excludedTypes": "Request"
            },
            "enableLiveMetricsFilters": true
        }
    }
}

I'm using the in-process model for the function. Here's a part of the csproj file:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net6.0</TargetFramework>
    <AzureFunctionsVersion>v4</AzureFunctionsVersion>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Azure.Data.Tables" Version="12.8.2" />
    <PackageReference Include="Azure.Storage.Blobs" Version="12.19.1" />
    <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Storage" Version="5.0.1" />
    <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="4.2.0" />
  </ItemGroup>
  <!-- ... files to copy to output/publish -->
</Project>

I'm guessing the HTTP trigger wakes the container up, but the blob trigger doesn't. What can I do about it?

1

There are 1 best solutions below

0
Pavan On

When I add a blob to my storage, hours go by without the function being triggered. Then I call the HTTP function (a simple function that just returns "hello") and all my pending blobs get processed.

I have created http trigger and blob trigger functions with runtime stack dotnet.

By using below code and configuration I am able to access the blobs in storage account container without accessing the http function.

Blob trigger function code:

using System;
using System.IO;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Host;
using Microsoft.Extensions.Logging;

namespace AzureFunctionsDemo
{
    public class ProcessJpegImage
    {
        [FunctionName("ProcessJpegImage")]
        public void Run([BlobTrigger("pavan/{name}", Connection = "AzureWebJobsStorage")]Stream myBlob, string name, ILogger log)
        {
            log.LogInformation($"C# Blob trigger function Processed blob\n Name:{name} \n Size: {myBlob.Length} Bytes");
        }
    }
}

Http trigger function code:

using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.Extensions.Logging;
using System.IO;
using System.Threading.Tasks;

public static class SayHello
{
    [FunctionName("SayHello")]
    public static IActionResult Run(
        [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequest req,
        ILogger log)
    {
        log.LogInformation("C# HTTP trigger function processed a request.");

        var message = "Hello!";
        return new OkObjectResult(message);
    }
}

host.json:

{
    "version": "2.0",
    "logging": {
        "applicationInsights": {
            "samplingSettings": {
                "isEnabled": true,
                "excludedTypes": "Request"
            },
            "enableLiveMetricsFilters": true
        }
    }
}

local.settings.json:

{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "your-storage account conn-string",
"FUNCTIONS_WORKER_RUNTIME": "dotnet"
}
}

When I ran the above function, it successfully processed all blobs in the container.

Output:

enter image description here

After I accessed the HTTP function URL, I received the following output:

enter image description here