I am working on an Azure Functions project, which needs to communicate with Azure Databricks Sql Warehouse via “Simba Spark ODBC Driver”.
This driver has a dependency on “libodbc.so.2” and “libltdl.so.7”.
Since the Azure Functions in inherently “serverless”, I have to rely on a customer Docker container to provide access to these shared libraries and drivers. In my Docker file I make a number of attempts to install these dependencies. When this container is built, I “/bin/bash” into it to see whether these libraries have been installed:
root@290c29da1110:/# cd /home/site/wwwroot/runtimes/linux-x64/native
root@290c29da1110:~/site/wwwroot/runtimes/linux-x64/native# ls
libgrpc_csharp_ext.x64.so libltdl.so.7 libodbc.so.2
root@290c29da1110:~/site/wwwroot/runtimes/linux-x64/native# ls -l
total 8500
-rwxr--r-- 1 root root 8214864 Jan 9 2023 libgrpc_csharp_ext.x64.so
-rw-r--r-- 1 root root 39368 Jun 12 22:28 libltdl.so.7
-rw-r--r-- 1 root root 443312 Jun 13 13:46 libodbc.so.2
root@290c29da1110:~/site/wwwroot/runtimes/linux-x64/native#
It is clear to me that these libraries are in fact installed.
However, when I run this container and trigger the function which it hosts, I still get this error:
Function.HttpExample.User[0]
The value of LD_LIBRARY_PATH: /lib:/usr/lib:/usr/lib/x86_64-linux-gnu:/home/site/wwwroot/runtimes/linux-x64/native
fail: Function.HttpExample.User[0]
An error occurred: Dependency unixODBC with minimum version 2.3.1 is required.
Unable to load shared library 'libodbc.so.2' or one of its dependencies. In order to help diagnose loading problems, consider using a tool like strace. If you're using glibc, consider setting the LD_DEBUG environment variable:
libltdl.so.7: cannot open shared object file: No such file or directory
Here is my entire Dockerfile:
FROM my-custom-dotnet-sdk:8.0-preview AS installer-env
# Use alternative Debian mirrors
RUN sed -i 's|http://deb.debian.org/debian|http://ftp.de.debian.org/debian|g' /etc/apt/sources.list &&
sed -i 's|http://deb.debian.org/debian-security|http://security.debian.org/debian-security|g' /etc/apt/sources.list
# Update package sources and install dependencies
RUN apt-get update &&
apt-get install -y curl apt-transport-https unixodbc-dev libsasl2-modules-gssapi-mit
# Copy the local Simba Spark ODBC Driver .deb file into the image
COPY simbaspark_2.8.0.1002-2_amd64.deb /tmp/simbaspark_2.8.0.1002-2_amd64.deb
COPY ./ini/odbc/* /usr/local/odbc/
COPY ./ini/simba.sparkodbc.ini /etc/
COPY ./ini/libltdl.so.7 /home/site/wwwroot/
COPY ./ini/libltdl.so.7 /home/site/wwwroot/runtimes/linux-x64/native/
# Install dependencies required by Simba Spark ODBC Driver
RUN apt-get update &&
apt-get install -y libsasl2-modules-gssapi-mit
# Install the Simba Spark ODBC Driver
RUN dpkg -i /tmp/simbaspark_2.8.0.1002-2_amd64.deb &&
apt-get install -f -y &&
rm /tmp/simbaspark_2.8.0.1002-2_amd64.deb
RUN apt-get install -f -y libltdl7
# Set environment variables for ODBC
ENV ODBCINI=/usr/local/odbc/odbc.ini
ENV ODBCSYSINI=/usr/local/odbc/
ENV SPARKINI=/etc/simba.sparkodbc.ini
ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib:/lib:/usr/lib:/usr/lib/x86_64-linux-gnu:/lib/x86_64-linux-gnu
# Ensure the target directory exists
RUN mkdir -p /home/site/wwwroot/runtimes/linux-x64/native
# Copy the ODBC library to the target directory
RUN cp /lib/x86_64-linux-gnu/libodbc.so.2 /home/site/wwwroot/runtimes/linux-x64/native/
RUN apt-get update && apt-get install -y libltdl7
# Set environment variable in runtime image as well
ENV LD_LIBRARY_PATH=/lib:/usr/lib:/usr/lib/x86_64-linux-gnu:/home/site/wwwroot/runtimes/linux-x64/native
# Copy and build your application
COPY . /src/dotnet-function-app
WORKDIR /src/dotnet-function-app
RUN mkdir -p /home/site/wwwroot &&
dotnet publish *.csproj --output /home/site/wwwroot
# To enable ssh & remote debugging on app service change the base image to the one below
# FROM mcr.microsoft.com/azure-functions/dotnet-isolated:4-dotnet-isolated8.0-appservice
FROM mcr.microsoft.com/azure-functions/dotnet-isolated:4-dotnet-isolated8.0
ENV AzureWebJobsScriptRoot=/home/site/wwwroot
AzureFunctionsJobHost__Logging__Console__IsEnabled=true
COPY --from=installer-env /home/site/wwwroot /home/site/wwwroot
Can anyone make a suggestion as to what needs to change in order for these dependencies to be satisfied?