Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running SSH script during Microsoft Azure Web App deployment

I am deploying a web app using the Python-Django framework to Microsoft Azure.

I have succeeded in deploying it, but every time I deploy, I have to open the Azure SSH tool and run the command apt-get install libgtk2.0-dev which I gather is some Linux dependency for the opencv-python image processing library.

I wonder if there is a way to install the required software using deploy.sh files.

deploy.sh

echo "Running Linux Deployment Script..."

apt-get update && apt install -y libxrender1 libxext6
apt-get install -y libfontconfig1
apt-get install libgtk2.0-dev

Thanks in advance for your help.

like image 413
Nadim Avatar asked Sep 02 '25 10:09

Nadim


2 Answers

You can create a script to install libgtk2.0-dev, say test.sh under /home/site. And then add an app setting under 'Configuration' called PRE_BUILD_SCRIPT_PATH with /home/site/test.sh as the value.

like image 69
sa23 Avatar answered Sep 05 '25 03:09

sa23


You can run a script on every Webapp startup. Just adjust your script as described here: https://stackoverflow.com/a/69923647/2606766

Create a start.sh file, e.g. like this:

# install package & start app
apt-get update -y
apt install -y libxrender1 libxext6
apt-get install -y libfontconfig1
apt-get install libgtk2.0-dev

# don't forget to start your webapp service at the end of this script, e.g.:
python manage.py runserver

Set it as your startup script:

enter image description here

Note: There are two pitfalls to this approach:

  1. The script must be executable, so either install w/ unix and chmod 755 start.sh or use a git command (see SO).
  2. The packages are installed on every startup, thus you depend on external servers/repositories when starting the webapp.
like image 36
HeyMan Avatar answered Sep 05 '25 02:09

HeyMan