Skip to content

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

Open
@flipmokid

Description

@flipmokid

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<String>).

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.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions