Skip to content
Advertisement

Azure Function timeout when accessing Blob

I have encountered a strange problem when accessing an Azure Storage Blob from an Azure Function. I have a Function written in Java which is supposed to download some data from a Blob and then execute a PowerShell command. The PowerShell command can launch another Java application, which accesses the same Blob. I have this process working except for where the Function first downloads the Blob, which always gives a timeout while trying to get the size.

The weird thing is that the Java application launched by the PowerShell command uses the same code to download the Blob and can do so without any trouble at all.

Here is the relevant code snippet:

try {
    blob = new BlobClientBuilder().endpoint(connStr).buildClient();
    int dataSize = (int) blob.getProperties().getBlobSize(); // <- timeout occurs here
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream(dataSize);
    blob.download(outputStream);
    outputStream.close();
    String result = new String(outputStream.toByteArray(), "UTF-8");
    return JsonParser.parseString(result).getAsJsonObject();
}
catch(Exception e) {
    System.out.println("ERROR: "+e.getMessage());
    e.printStackTrace();
    return null;
}

Some relevant info: The Blob is very small – only a few KB.
The same connection string is used in both cases.
The Blob is not the trigger for the function, but rather stores data for it.

EDIT

After getting better logs with a Log Analytics workspace, I found the timeout is being caused by a NoSuchMethodError.

java.lang.NoSuchMethodError: io.netty.handler.ssl.SslProvider.isAlpnSupported(Lio/netty/handler/ssl/SslProvider;)Z

I’ve seen this error before when I had the wrong version of netty-all-x.x.xFINAL.jar. Having already fixed this in the jars I upload with my code, I am now wondering where the Function gets libraries from other than what I include.

Advertisement

Answer

Following the exception mentioned in the edit led me to this thread: https://github.com/Azure/azure-functions-java-worker/issues/381.

The issue was that the dependencies for the Function App itself were loading before my dependencies for my code and there is a conflict between them as mentioned here: https://github.com/Azure/azure-functions-java-worker/issues/365.

The solution was to set FUNCTIONS_WORKER_JAVA_LOAD_APP_LIBS = 1 in the Configuration settings of the Function App.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement