0

I am trying to trigger a webjob when a new file is placed in blob in java , I have started using blob trigger azure function , but instead of processing newly added or updated files it is processing all files in the blob. Below is the code snippet

public class BlobTriggerFunction {
/**
 * This function will be invoked when a new or updated blob is detected at the specified path. The blob contents are provided as input to this function.
 */
@FunctionName("BlobTrigger-Java")
@StorageAccount("AzureWebJobsStorage")
public void run(
    @BlobTrigger(name = "content", path = "snowflake/assets_group/{name}", dataType = "binary") byte[] content,
    @BindingName("name") String name,
    final ExecutionContext context
) {
    context.getLogger().info("Java Blob trigger function processed a blob. Name: " + name + "\n  Size: " + content.length + " Bytes");
} 

Below is the console which is processing all files enter image description here

Geeth
  • 19
  • 5

1 Answers1

0

I have started using blob trigger azure function, but instead of processing newly added or updated files it is processing all files in the blob.

There may be a bug in the Azure Functions runtime or the Blob Storage SDK that is causing the function to process all files in the container.

Try updating to the latest version of the Azure Functions runtime or the Blob Storage SDK to see if that resolves the issue.

And also, create a new blob trigger azure function and check again if it is still happening. Because, as per my observation it will process only newly added files in the blob.

I have tried the same in my environment and could process the newly added files in the container.

Code Snippet:

import com.microsoft.azure.functions.annotation.*;
import com.microsoft.azure.functions.*;


public class BlobTriggerJava1 {
   
    @FunctionName("BlobTriggerJava1")
    @StorageAccount("AzureWebJobsStorage")
    public void run(
        @BlobTrigger(name = "content", path = "samples-workitems/access_files/{name}", dataType = "binary") byte[] content,
        @BindingName("name") String name,
        final ExecutionContext context
    ) {
        context.getLogger().info("Java Blob trigger function processed a blob. Name: " + name + "\n  Size: " + content.length + " Bytes");
    }
}

Files uploaded in the Blob: enter image description here Console output after adding a file: enter image description here

Output after adding a new files to the existing container(which has files): enter image description here enter image description here

Pravallika KV
  • 2,415
  • 2
  • 2
  • 7