2

On Azure Linux App service, while deploying a flask app i get following error:

2019-05-12T13:07:29.931475061Z A P P   S E R V I C E   O N   L I N U X
2019-05-12T13:07:29.931478561Z 
2019-05-12T13:07:29.931481661Z Documentation: http://aka.ms/webapp-linux
2019-05-12T13:07:29.931484961Z 
2019-05-12T13:07:30.016820049Z Starting OpenBSD Secure Shell server: sshd.
2019-05-12T13:07:30.026671394Z Site's appCommandLine: startup.sh
2019-05-12T13:07:30.055028087Z Checking of startup.sh is a file
2019-05-12T13:07:30.082487648Z App command line is a file on disk
2019-05-12T13:07:30.082508249Z App command line is a shell script, will execute this script as startup script
2019-05-12T13:07:30.082513649Z Launching oryx with: -appPath /home/site/wwwroot -output /opt/startup/startup.sh -virtualEnvName antenv -defaultApp /opt/defaultsite -userStartupCommand startup.sh
2019-05-12T13:07:30.082479048Z Oryx Version : 0.2.20190401.5, Commit: c7bcd3a2b802e109512924fbcf208bf77bf6cc6e
2019-05-12T13:07:30.082553451Z 
2019-05-12T13:07:30.851365669Z Writing output script to '/opt/startup/startup.sh'
2019-05-12T13:07:30.893829956Z Using packages from virtual environment 'antenv' located at '/home/site/wwwroot/antenv'.
2019-05-12T13:07:30.904225020Z /opt/startup/startup.sh: 39: /opt/startup/startup.sh: startup.sh: not found

The startup.sh file is in /site/wwwroot and the content is as follows:

#!/bin/bash
source antenv/bin/activate
gunicorn --bind=0.0.0.0 --timeout 600 app:app

Any idea on what is leading to this error?

Zedi10
  • 115
  • 2
  • 10
  • [Why is #!/usr/bin/env bash superior to #!/bin/bash?](https://stackoverflow.com/q/21612980/608639) – jww May 12 '19 at 15:21

3 Answers3

3

We had the same problem when there was a problem with the line endings in the file, because it was edited in Notepad. Try the sed editor to fix it: sed -i -e 's/\r$//' <path_to_sh_file>

lienn
  • 112
  • 7
  • Absolutely brilliant! I've been working on this for 3 hours without any progress. Ran the one command above and it fixed it all. That's amazing! +1 my friend. – War10ck Sep 30 '21 at 15:42
  • yes, I had an extra line break in my file. Just deleted the line and it now works. – June May 17 '22 at 15:44
1

You should be able to customize the Python application command by following this document: https://learn.microsoft.com/en-us/azure/app-service/containers/how-to-configure-python#customize-startup-command

Example (This can be added in the Startup Command): gunicorn --bind=0.0.0.0 --timeout 600 hello:myapp

To understand how the command works, you can take a look into the init_container.sh script here: https://github.com/Azure-App-Service/python/blob/master/3.7.0/init_container.sh

Gaurav Kumar
  • 136
  • 8
0

You can also check the Configuration Settings under General settings in Azure Portal:

Check the setup in the link below for both Flask and Django Application setup:

https://learn.microsoft.com/en-us/azure/developer/python/configure-python-web-app-on-app-service#create-a-startup-file

ShaviyaVictor
  • 1
  • 1
  • 1
  • 3
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Nov 12 '22 at 21:49