Azure / Azure/azure-functions-java-worker

Query about the viability of creating an Azure Function using a dynamic JVM language

未关闭
#359 0 条评论 0 个 reaction 已指派 1 人 在 GitHub 查看

@kamperiadis 已经在做这个了。

开始于 2023年2月27日。

area:java-functions Enhancement New Feature reviewed
主要语言
Java
星标
103
派生
74
平均合并
4 天 8 小时
30 天内合并 PR
2

描述

I've been trying to setup an Azure Function using a dynamic JVM language (Clojure). With Clojure it is possible to put type hints on function arguments which are then present in the bytecode but it is not possible, as far as I understand, to add the type of a generic (i.e. I can define an argument to be a List but cannot define it to be a List\).

The documentation (https://github.com/Azure/azure-functions-java-library) seems to suggest that an Azure function can be created without type annotations, using function.json instead. However when I try to do this locally I get an error,

```
Executed 'Functions.PnlFunction' (Failed, Id=725a837b-f380-4eb0-9594-d632efe7efb8)
System.Private.CoreLib: Exception while executing function: Functions.PnlFunction. System.Private.CoreLib: Result: Failure
Exception: ClassCastException: com.microsoft.azure.functions.worker.binding.ExecutionContextDataSource cannot be cast to java.lang.String
Stack: java.lang.ClassCastException: com.microsoft.azure.functions.worker.binding.ExecutionContextDataSource cannot be cast to java.lang.String
at com.microsoft.azure.functions.worker.binding.DataOperations.apply(DataOperations.java:99)
at com.microsoft.azure.functions.worker.binding.DataSource.computeByType(DataSource.java:56)
at com.microsoft.azure.functions.worker.binding.BindingDataStore.getDataByType(BindingDataStore.java:63)
at com.microsoft.azure.functions.worker.broker.ParameterResolver.resolve(ParameterResolver.java:65)
at com.microsoft.azure.functions.worker.broker.ParameterResolver.resolve(ParameterResolver.java:42)
at com.microsoft.azure.functions.worker.broker.JavaMethodExecutor.execute(JavaMethodExecutor.java:52)
at com.microsoft.azure.functions.worker.broker.JavaFunctionBroker.invokeMethod(JavaFunctionBroker.java:53)
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:92)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
```

where it looks like the Azure lib is trying to find some type information and cannot.

I was hoping that the "dataType" attribute in the bindings section of function.json could be used instead of reflecting over the code so that dynamic JVM languages can be used more easily to create Azure functions. Does anyone know if it's possible?

Unfortunately I've not stuck to template used, as the query is more general, and is around whether it's possible to avoid reflection over my code and instead use the function.json file.

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。