简体   繁体   中英

Azure Function Java BindingName for Blob Storage (event-based) is not working

I followed the instructions from the below url and got this to work.

https://learn.microsoft.com/en-us/azure/azure-functions/functions-event-grid-blob-trigger?pivots=programming-language-java

However, I get a null pointer exception when I use @BindingName("name").

[2023-01-24T03:35:11.842Z] Executed 'Functions.BlobTriggerEventGrid' (Failed, Id=9945bf16-f234-4a76-8f4d-ba98ba7856f6, Duration=192ms)
[2023-01-24T03:35:12.013Z] System.Private.CoreLib: Exception while executing function: Functions.BlobTriggerEventGrid. System.Private.CoreLib: Result: FailureException: NullPointerException:
Stack: java.lang.NullPointerException
[2023-01-24T03:35:12.076Z]      at com.microsoft.azure.functions.worker.binding.BindingDataStore.getTriggerMetatDataByName(BindingDataStore.java:66)
[2023-01-24T03:35:12.083Z]      at com.microsoft.azure.functions.worker.broker.ParameterResolver.resolve(ParameterResolver.java:62)
[2023-01-24T03:35:12.137Z]      at com.microsoft.azure.functions.worker.broker.ParameterResolver.resolve(ParameterResolver.java:42)
[2023-01-24T03:35:12.139Z]      at com.microsoft.azure.functions.worker.broker.EnhancedJavaMethodExecutorImpl.execute(EnhancedJavaMethodExecutorImpl.java:53)
[2023-01-24T03:35:12.384Z]      at com.microsoft.azure.functions.worker.broker.JavaFunctionBroker.invokeMethod(JavaFunctionBroker.java:62)
[2023-01-24T03:35:12.387Z]      at com.microsoft.azure.functions.worker.handler.InvocationRequestHandler.execute(InvocationRequestHandler.java:33)
[2023-01-24T03:35:12.451Z]      at com.microsoft.azure.functions.worker.handler.InvocationRequestHandler.execute(InvocationRequestHandler.java:10)
[2023-01-24T03:35:12.452Z]      at com.microsoft.azure.functions.worker.handler.MessageHandler.handle(MessageHandler.java:45)
[2023-01-24T03:35:12.453Z]      at com.microsoft.azure.functions.worker.JavaWorkerClient$StreamingMessagePeer.lambda$onNext$0(JavaWorkerClient.java:92)      
[2023-01-24T03:35:12.472Z]      at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
[2023-01-24T03:35:12.562Z]      at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[2023-01-24T03:35:12.569Z]      at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
[2023-01-24T03:35:12.629Z]      at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
[2023-01-24T03:35:12.963Z]      at java.base/java.lang.Thread.run(Thread.java:834)

I tried adding the name as a property in the delivery properties but that didn't work.

Any thoughts?

I tried to reproduce your issue which is the same to me but didn't find the specific cause for that exception in my test cases.

Following the Same doc, Created Storage Account, Blob Triggered Java Azure Function with ngrok Utility Endpoin t given as a Web Hook Endpoint in Azure Event Subscription referenced to Blob Storage created earlier.

Test Case 1 :

When I run the Function for the 1st time - uploaded a blob and overwritten the blob upload manually in the Blob Storage container. At that time, I got the RuntimeException: Cannot find matched @BindingName immediately after 1st Run with the Successful Trigger output:

在此处输入图像描述

在此处输入图像描述

Test Case 2 :

During the same time of Function running with both the Blob Trigger File Upload Response and Runtime exception, I uploaded another blob file and got the expected result as Blob Trigger Response without any exception again and the Events also updated:

在此处输入图像描述

Test Case 3 :

I have Stopped the Azure Function running locally in VS Code and Started again by uploading the new blobs in the Storage Container associated with it. Then, I did not get any runtime exceptions:

在此处输入图像描述

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM