gpt4 book ai didi

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

转载 作者:搜寻专家 更新时间:2023-10-31 20:25:18 24 4
gpt4 key购买 nike

我创建了一个函数,在创建或更新 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com