Reputation: 949
This is the first time I am deployed a python web service on Azure App service and have not been able to resolve the issue I am facing. Hence, looking for help!
I have developed a very simple Flask app and have deployed it to Azure App Service, via VS code. I have the following piece of simple code, which expected to run and display output on the home page of the application.
@app.route('/')
def get():
print('In Get()')
return "My Server Running !!!"
The deployment is successful! However, the home site https://appname.azurewebsites.net/ does not execute the above code!
When I log into SSH through Azure portal, and run a curl command to check output on port 8000, I get the response of "My Server Running !!!".
That means the flask server is running, but how do I access it from App service ?
Can someone tell me what I am missing?
Upvotes: 3
Views: 2942
Reputation: 949
Answering my own question here ...
I tried deploying the app without the app.run() piece of code (as it too was not there as part of the azure app service tutorial on MS website) and it worked. Looks like Azure uses the flask run option and for some reason adding app.run() seems to break it.
You may find more information flask run and app.run() here
Happy coding!
Upvotes: 2
Reputation: 222722
There are you things you can check,
(i) Add the application root in the AppSettings,
(ii) Try running the app in different port
HOST = environ.get('SERVER_HOST', 'localhost')
try:
PORT = int(environ.get('SERVER_PORT', '8000'))
except ValueError:
PORT = 8000
app.run(HOST, PORT)
Upvotes: 5