Pyodbc is an open-source Python module that helps in accessing ODBC database.
The following blog explains on how this module can be used for Linux based Azure App Service.
The folder structure is as follows :
A Dockerfile is a text document that contains all the commands a user could call on the command line to assemble an image. This file is necessary when you’re creating a custom docker container image.
As you can see from the contents of my Dockerfile, I’ve mentioned the pre-requisites needed to install pyodbc: apt-get update and apt-get install -y --no-install-recommends build-essential gcc unixodbc-dev. Once the pre-requisites are installed, I install requirements.txt in my image. I also installed SSH on the image, since SSH needs to be specifically enabled on custom images.
Here’s what my requirements.txt looks like:
The entry point for my App is init.sh and does 2 things:
Now since pyodbc has been successfully installed already, it can be directly.
The following is my sample App Service that that return the first cell value from a given tableName
To build this image, make sure you have the Docker Extension installed on Visual Studio Code. Once you have this installed, you can easily, build the image by Right click Dockerfile > Build Image.
I connected my VSCode to my Dockerhub account and pushed my image to my Dockerhub repository on hub.docker.com.
You can choose to push your image to Dockerhub or Azure Container Registry or a private registry of your choice.
Here’s the link to the custom image pushed to DockerHub:
The following steps could help you deploy the above image to your Linux based App Service in case you would like to test it.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.