5
votes

I create a function to trigger when blob storage is being create or update. My blob structure : container/a-123/b-123/c-1-2-3

while 123 is a dynamic value

And here my function

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("blobtriggerfunction")
@StorageAccount("connection")
public static void run(
        @BlobTrigger(name = "container", path = "container") CloudBlockBlob cloudBlockBlob,
        @BindingName("name") String name,
        final ExecutionContext context
) {
    context.getLogger().info(cloudBlockBlob.getUri().toString());
    context.getLogger().info(name);
}

}

And I always get the error

Executing 'Functions.blobtriggerfunction' (Reason='New blob detected: container/u-123/c-123/m-1-2-3-a50a-025592397574', Id=6b9ae40c-f92b-46d4-8c1-41791167c355) Cannot locate the method signature with the given input System.Private.CoreLib: Exception while executing function: Functions.blobtriggerfunction. System.Private.CoreLib: Result: Failure Exception: Cannot locate the method signature with the given input Stack: java.lang.NoSuchMethodException: Cannot locate the method signature with the given input at com.microsoft.azure.functions.worker.broker.JavaMethodExecutor.lambda$execute$0(JavaMethodExecutor.java:49) at java.util.Optional.orElseThrow(Optional.java:290) at com.microsoft.azure.functions.worker.broker.JavaMethodExecutor.execute(JavaMethodExecutor.java:49) at com.microsoft.azure.functions.worker.broker.JavaFunctionBroker.invokeMethod(JavaFunctionBroker.java:47) at com.microsoft.azure.functions.worker.handler.InvocationRequestHandler.execute(InvocationRequestHandler.java:33) at com.microsoft.azure.functions.worker.handler.InvocationRequestHandler.execute(InvocationRequestHandler.java:10) at com.microsoft.azure.functions.worker.handler.MessageHandler.handle(MessageHandler.java:45) at com.microsoft.azure.functions.worker.JavaWorkerClient$StreamingMessagePeer.lambda$onNext$0(JavaWorkerClient.java:91) at java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1386) at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289) at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056) at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692) at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)

What wrong with my method signature, I go stuck on this. I am really appreciate for your help.

1
Is this cloudBlockBlob.getUri() necessary for your further development or you just want to output it for test? - Jerry Liu
It doesn't really need - Sophon Men

1 Answers

3
votes

Data type CloudBlockBlob is not supported in java blob trigger. For this reason, you can't get blob url unless you use azure storage sdk inside your function.

We can use String, byte[], POJO class for java blobtrigger content binding. See the Document.

For example

@BlobTrigger(name = "content", path = "container/{name}", dataType="Binary") byte[] content

Note that if you want to use blob name, you should append path with /{name}, or you will get the same error.

And I recommend you to keep value of annotation parameter name identical to incoming blob name(As I have set both of them to content). It's not necessary to make function work, but for better understanding.