AzurePostGIS
Enabling PostGIS + GeoDjango on Azure
In order to use GeoDjango and PostGIS, we need GDAL (Geospatial Data Abstraction Library), PROJ (Cartographic Projections library), and GEOS (Geometry Engine Open Source); installed into Azure. Big Oof. Also, on Azure we need to enable PostGIS, but this is easy.
Enable on the database server
- Go to the server resource.
- Then under settings go to ‘Server Parameters’
- In the search bar, type ’extensions’ and click on the dropdown of ‘azure.extensions’.
- Select ‘POSTGIS’
- Save
IMPORTANT: In Azure, PostGIS is not available for PostgreSQL16 yet, only until 15! https://learn.microsoft.com/en-gb/azure/postgresql/flexible-server/concepts-extensions?WT.mc_id=Portal-Microsoft_Azure_OSSDatabases#extension-versions
Create a Docker Image on Azure using Azure Container Registry
See post
Install GDAL
See the following blogpost: https://learn.microsoft.com/en-us/answers/questions/1287370/azure-web-app-gdal-support
First of all, GeoDjango requires GDAL 3.7 as the highest version. For local its easy to update this to 3.8. For Azure probably not. Make sure to install version 3.7.3 (see https://gdal.org/download.html)
Azure runs on linux, so we need linux commands to install GDAL. Luckily this is so much easier than on Windows. Run this in the SSH of the App Service.
| |
If this doesnt work, install a custom wheel of GDAL, see the last comment in the post.