javaazureazure-blob-storageazure-blob-trigger

Is there any way to get the file content which is triggring azure blob trigger?


So I have created a Azure blob trigger, and it is working fine as soon as I put some file or create some directory on the blob the trigger happens.

Question: Now I can not figure out how can I get the same file content which causes the blob trigger.

I can get the files using Azure storage library, but I am going to upload lots of files on the blob and want to do some processing on the file which has just written on the blob.

Thanks in advance


Solution

  • It looks pretty straightforward from the example documentation - https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-storage-blob#trigger---java-example

    @FunctionName("blobprocessor")
    public void run(
        @BlobTrigger(name = "file",
                     dataType = "binary",
                     path = "myblob/{name}",
                     connection = "MyStorageAccountAppSetting") byte[] content,
        @BindingName("name") String filename,
        final ExecutionContext context
    ) {
        context.getLogger().info("Name: " + filename + " Size: " + content.length + " bytes");
    }
    

    The content gets passed in as a byte array.