Azure Web App GDAL Support

Todd Player 5 Reputation points
2023-05-18T21:37:33.3733333+00:00

Hello,

I have a Python / Django / Postgres / PostGIS application I was trying to run on an Azure App Service. The problem I am having is with GDAL. This is on Linux not Windows. I get an error when the app starts that it cannot find the GDAL libraries. I have tried a number of approaches to try to fix it, including adding a startup command "apt-get update && apt-get -y install binutils libproj-dev gdal-bin". The startup command seems to work correctly and install GDAL and the other components but then the app just fails to start reporting an unknown error. This leads me to think that GDAL might not be supported under the Azure App Service but I wanted to check and see if anyone else might have figured this out.

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,930 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Grmacjon-MSFT 19,151 Reputation points Moderator
    2023-07-11T05:39:37.8733333+00:00

    @Todd Player thanks for your patience. It is possible to use GDAL with Azure App Service, but there are some limitations and considerations that you need to keep in mind.

    -First, Azure App Service runs on a Linux-based environment, so you need to make sure that you are using the Linux version of GDAL. You can install GDAL on Linux using the package manager of your Linux distribution. For example, on Ubuntu, you can install GDAL using the following command**:**

    sudo apt-get install gdal-bin
    

    -Second, you need to make sure that the GDAL libraries are in the search path of your Python application. You can do this by setting the LD_LIBRARY_PATH environment variable to include the directory where the GDAL libraries are installed. For example, if you installed GDAL using the command above, you can set the LD_LIBRARY_PATH environment variable as follows:

    export LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu/
    

    You can set this environment variable in your Azure App Service by adding an application setting with the name LD_LIBRARY_PATH and the value /usr/lib/x86_64-linux-gnu/.

    -Finally, you need to make sure that your Python application is using the correct version of GDAL. You can do this by installing the GDAL Python package using pip. For example, you can install the GDAL package using the following command

    pip install GDAL==<version>
    

    Make sure to replace <version> with the version of GDAL that you installed on your Linux environment.

    If you have followed these steps and are still experiencing issues, you can try enabling the detailed error logging in Azure App Service to get more information about the error. You can do this by setting the WEBSITE_WEBDEPLOY_USE_SCM application setting to true and then accessing the Kudu console for your app service. From the Kudu console, you can view the detailed error logs and troubleshoot the issue further.

    -Grace

    0 comments No comments

  2. Granada, Luis 5 Reputation points
    2023-07-11T07:29:05.98+00:00

    Hello @Todd Player ,

    I had the same problem and I solved it by installing a custom GDAL wheel for Linux since the web app is installed on Linux. Before deploying, I replaced:

    GDAL==3.7.0
    

    in the "requirements.txt" file with

    ./wheelhouse/GDAL-3.4.1-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.whl
    

    And then I stored the file "GDAL-3.4.1-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.whl" inside a folder called "wheelhouse" inside the project. Then I deployed to Azure Web Apps. For me this worked!

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.