how to view/edit files uploaded to Azure webapp? - python

I got my first flask webapp (hello.py) working (deployed) on Azure. I want to add more functionality to this webapp. According to documentation I am following
(https://medium.com/#nikovrdoljak/deploy-your-flask-app-on-azure-in-3-easy-steps-b2fe388a589e)
I should test my files (hello.py, home.html etc) locally and use git push to send new files to Azure cloud. I should restart my application to see changes.
(1) Is there a way to edit these files on Azure cloud using say emacs ?
(2) Related to (1) on which path do these files exist on Azure ? I clicked on cloudshell and a terminal popped up. It is apparently my home directory. I can see only one directory (clouddrive). I cannot see hello.py. I also went to .scm.azurewebsites.net and clicked on bash. I do get a command prompt but cannot see hello.py.
Thanks.

Under Development Tools you should have App Service Editor (Preview)
If you click on that it should allow you to edit the files via the portal.

Related

How to locally edit an already deployed function in Azure Functions (Python)?

After having worked on a Azure Functions application, i have now deployed the app and had it running for a while. Now I want to continue my work on another computer, however I cant seem to identify any way to download the source code in either VS Code nor Azure Portal?
For python function we can not download the content from Azure portal or VS code. It is in read-only mode.
Workaround:
1.Copy your project to another computer.
2.Create a new project on another computer and copy the main files from azure portal.
host.json and requirements.txt files from App files.
init.py and function.json files from Code+Test.

Deploying Django App on PythonAnywhere without using GitHub

I need to deploy a Django app on pythonanywhere, but I wish I could upload the code without using GitHub because I don't have private repositories and I don't want my codes to be exposed to the public.
How can I deploy my Django app on pythonanywhere without using GitHub?
According to their documentation, you can upload your project as zip to pythonanywhere. Have in mind that if the project is big enough you have to split it into parts.
Steps
Make a zip file ( split it to parts if needed)
Uploaded to pythonanywhere using the Files Tab
Use the bash console and the unzip command to decompress it
Done
More Info here
See the documentation of python anywhere
https://help.pythonanywhere.com/pages/DeployExistingDjangoProject/

Flask app doesn't builds on MS Azure cloud

I want to deploy my flask web application on Azure cloud. In Deployment options, I have selected GitHub as source destination for my flask code. after doing the configuration test successfully, the init.py file now starts building;
Now when I go to my application link, it shows me this;
Now at this point, I went back to my deployment options, it says Building failed;
the log generated for this building failed can be seen in the first picture. All the tests has passed except the last one "Performance test". Have anyone encountered the same issue before ? what can be the reason for that ?
I am running the application on localhost # port 8000.
from flask import Flask
app = Flask(__name__)
#app.route("/")
def hello():
return "Hello World!"
if __name__ == "__main__":
app.run()
Do I need to run it on another IP ?
You cannot listen on port 8000 in Web Apps. Only port 80 or 443. You'll need to read the port number from the environment, to know what to listen on.
If you created the Azure Webapp using the Flask tool, the default app is called FlaskWebProject1. If your app has a different name, you need to modify web.config in your wwwroot folder to reflect the correct app name.
Then redeploy using the Azure portal or change it in your GIT and push again.
Based on your 500 error, I think some python packages are not installed correctly.
To check your code is working correctly in naive manner, do as follows.
If you are developing on Windows machine, copy all of your site-packages files in development machine to WebApp /site/wwwroot/env/Lib/site-packages folder.
Hit Restart in Azure Portal and F5 in browser.
If it works, your deployment process might have a problem. Mainly it is caused by library installation.
First, check you have requirements.txt at the root folder. This documentation describes some considerations to load Flask on Azure WebApp. Of course, it would be really helpful to read the documentation from the first line carefully.
Second, login WebApp via FTP and check the package is installed correctly. You can see /pip folder has pip.log file, and /site/wwwroot/env/Lib/site-packages folder has its libraries.
For some libraries which you might require more than simple hello world app, you may have to push x86 .whl files along with python codes as they are not installed correctly in x86 environment.
Additionally, in order to show internal error to outside, consider to apply this option during development (not for production).

Can't find `FlaskWebProject` files in Azure set-up

I am trying to run through the creation of a Flask web app in Azure using this instruction page.
Creating Web apps with Flask in Azure
In the "Application Overveiw" section, it lists some FlaskWebProjectfiles saying.
Here's an overview of the files you'll find in the initial Git repository
\FlaskWebProject\__init__.py
\FlaskWebProject\views.py
\FlaskWebProject\static\content\
\FlaskWebProject\static\fonts\
\FlaskWebProject\static\scripts\
\FlaskWebProject\templates\about.html
\FlaskWebProject\templates\contact.html
\FlaskWebProject\templates\index.html
\FlaskWebProject\templates\layout.html
The problem is that I don't get these files when I connect up Azure to a Github repository. I know they exist because my Azure app renders the this default Flask webapp. The files exist in /wwwroot.
I am sure that I am missing something obvious here, so if anyone has followed the most recent Flask setup instruction for Azure, and had success, their input would be great.
Your initial GitHub repository is empty, so you need to clone the repository.
The process is described in the same article you mentioned, but a little later.
Basically:
1) Go to the deployment source and configure the deployment source - for example, local github
2) Go to Settings => Properties. Here you should have Git URL where your files are placed
3) Go to your workstation, and execute
git clone https://yourdeploymentusername#todeleteflask.scm.azurewebsites.net:443/todeleteflask.git
Enter password.
You should be all set now. Now, if you make change, you may push to the repository and it will arrive on the site.

Flask Site on Azure showing default landing page

I have a site that's running fine locally. I used this resource (https://azure.microsoft.com/en-us/documentation/articles/web-sites-publish-source-control/) to push it up to my Azure Flask web app via Git. However, when navigating to the url given by the project:
it looks like this:
, which is not my home page. Any idea why this is happening or what I can do to fix it? Thanks!
Per my experience, assumption that you created the webapp for using Flask via creating a Flask template from gallery on Azure old portal or from marketpacke on Azure new portal, so that the template project for Flask called FlaskWebProject would be created by following the webapp. You can see the template project at the path \site\wwwroot of the Kudu console http://<your-webapp-name>.scm.azurewebsites.net/DebugConsole.
Therefore, you need to cover the project with your project called the same name via Git. Your project directory must be in the root path of Git repository.
The root path of Git repo
|- FlaskWebProject
|- ...
Then, it will cover the old project when you pull the git repo via continuous deployment on Azure.
If using Visual Studio as your default IDE, you can refer to the doc https://azure.microsoft.com/en-us/documentation/articles/web-sites-python-create-deploy-flask-app/.

Categories

Resources