java - Azure函数无法找到具有给定输入的方法签名

标签 java azure azure-functions azure-blob-storage

我创建了一个函数,在创建或更新 Blob 存储时触发。 我的blob结构:container/a-123/b-123/c-1-2-3

而123是一个动态值

这是我的函数

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);
}

}

我总是收到错误

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)

我的方法签名出了什么问题,我陷入了困境。 我非常感谢您的帮助。

最佳答案

Java Blob 触发器不支持数据类型 CloudBlockBlob。因此,除非您在函数中使用 azure storage sdk,否则您无法获取 blob url。

我们可以使用Stringbyte[]、POJO类进行java blobtrigger内容绑定(bind)。请参阅Document .

例如

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

请注意,如果您想使用 blob 名称,则应在路径后附加 /{name},否则您将收到相同的错误。

我建议您将注释参数name的值保持与传入的blob名称相同(因为我已将它们都设置为content)。使函数正常工作并不是必需的,而是为了更好地理解。

关于java - Azure函数无法找到具有给定输入的方法签名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51167580/

相关文章:

java - servlet如何处理一次请求中上传多个文件

java - 如何在 GL Linux Server 命令行中使用 Java GUI?

azure - 使用 Azure PowerShell 同时停止多个 Azure VM

azure - 更改 Azure APIM 响应中的 Set-Cookie 路径

Azure Synapse 工作区 : Where the scripts are published?

azure - 更新管道时 Azure 函数缺少 dll 错误

java - 字符串池与常量池

java - JTable动态JCheckBox需要1次点击取消勾选,2次点击勾选

azure - 当出站 TCP 端口耗尽时,消费计划中的 Azure Functions 会如何表现?端口限制是多少?

c# - 如何添加对 Azure Function C# 项目的引用?