Deploy Django App on Azure: only displays default app, even after deployment - django

I am trying to deploy a webapp to Azure. I am following these directions https://azure.microsoft.com/en-us/documentation/articles/web-sites-python-create-deploy-django-app/
First step, I created a webapp (Django) on the portal.
Then it says to follow the directions to configure Continuous deployment using GIT in Azure App Service. This should apparently lead to my having a local directory of Django files. https://azure.microsoft.com/en-us/documentation/articles/web-sites-publish-source-control/
So I follow those directions, installing Git, creating a local repository, adding a webpage, enabling web app repository, deploying.
The webportal now shows that I have deployed ('active' deployment). However, when I go to the web app url, what's showing is NOT what I deployed, but rather what I guess is the default Django app with its urls (login, logout, contacts).
So then I create an actual Django app in my local directory (instead of the static index.html from the directions). I commit and push it to Azure. It shows as being deployed.
The result is the same as before: the default web app is showing.
So what I'm missing is the connection between my local repository and what's actually showing. Is there some way to pull the Azure default app into my local repository? (Once it's there, I'll be able to change it as I see fit.)

Things are working as expected, but you ended up overwriting the Django app in your first the Git commit. The Continuous Deployment instructions as written are generic to any deployment, even a blank Web App.
So what I'm missing is the connection between my local repository and what's actually showing. Is there some way to pull the Azure default app into my local repository? (Once it's there, I'll be able to change it as I see fit.)
All you need to do is git clone your repo after you've initialized your local Git repo on the Azure Web App. You've already gone through most of these steps, but I'll include them here for others who may be looking for this answer.
After you create the Django Web App from the Azure Marketplace/Gallery, scroll down to set up continuous deployment.
Choose Local Git repo.
Notice that you now have a Git Clone URL in both your Quickstart Essentials info and under All Settings >> Properties. Go ahead and copy this URL.
If you haven't already done so, you may need to set or reset your Deployment Credentials. You'll find this under All Settings. This will be your Git & FTP credentials. Note that this is actually the credentials for your Microsoft Account, not just this one Web App.
You already have Git installed from your first attempt. You should now be able to navigate to the folder you want to clone the repo into and run:
git clone <your_git_clone_url>
After you type in your password, you'll have a cloned repo of the Django Web App on your local system. cd into the directory and start working from there. Once you have changes, git add ., git commit, and git push them back to the repo in Azure to see your changes there.

Related

Updating code on Digital Ocean via GitHub

I have a Django app on Digital Ocean https://chicagocreativesnetwork.com/ which was uploaded via GitHub.
I need to make some changes to the CSS and HTML for this app, which I am doing locally and pushing to my GitHub repository.
How do I get the pushed GitHub updates into my Digital Ocean app?
How was the app uploaded to your Digital Ocean droplet exactly? Was the repo cloned or forked to the droplet?
Read the Caution at the end first
You could always go into your droplet console move to the directory where your project is in. Then do:
git status (to see the state of your repo)
then do git fetch (to fetch the changes from your origin to your droplet repo)
do a git status again (to see how many steps your droplet is behind your remote
repo)
if you see everything is ok and it says you are '1 commit behind master'(if you are changing for the first time after deployment)
Go ahead and git pull (with github username and personal access token as password)
do a final git status it should now say 'you are up-to date with remote'
CAUTION - do not git push anything from your droplet console into your remote repo even if git status shows files ready to be staged and committed in red.
These files are local to the droplet repo and should stay as they are. Any change you make should come from -
Local changes pushed to your remote repository
Going into your droplet console and Pulling the changes into your droplet repository
The workflow is detailed more clearly in the following comment:
https://stackoverflow.com/a/42001608/2155469

Deploy Django app on Microsoft Azure with Local Package

I would like to deploy an Django App on to Microsoft Azure through the App Service.
In the requirements.txt I have a package that I wrote myself and need to install from local directory which is in the same directory as manage.py.
I have tried to deploy the app through local git, and everytime it is running into the error it is not able to import the local package although it is able to install it with no problem in "antenv" (the virtual env Azure creates automatically)
NEWEST
In azure webapp, it not support venv.
Suggestion:
You can copy and paste local package to site-packages folder to test, if not works, you should use docker container to test. But also need to add local package manually.
PRIVIOUS
I test it and it works fine.
I will share my test steps for you.
Step 1. Run successfully in local.
Step 2. Push project to https://yoursite.scm.azurewebsites.net/yourproject.git
You can follow the offical doc(Local Git deployment to Azure App Service).
Step 3. Visit your website.
You can download my sample code in github. You also need to add pyodbc then you can get same result with me. For more details, pls check this post(How to access ODBC Driver on Azure App service).

Django Web application publishing

How to publish django web application? what are the steps to be followed for publishing a django application? is there any free hosting for pulishing?
thanks in advance
I am using PythonAnyWhere for hosting my project. They provide hosting for python-Django / flask specificly and have a very dedicated team.
You can host your app for free but you can not use your own domain. To use custom domain, you need to purchase paid plan starting from $5 per month.
Their customer support is extremly good.
Steps to follow for hosting:
- Make sure your code is production ready i.e. well tested and bug free.
- Separate production and dev settings file. On production you need to set DEBUG=false.
- Push your code to github. Do not commit sensitive information like credentials or api keys. Keep them in .env file.
- Create account on pythonanywhere server and create database.
- Clone the git repo. Complete the web setup step. Edit the wsgio settings file.
- Run migrations. python manage.py migrate.
- Create cache table if any python manage.py createcachetable.
- Collect static files python manage.py collectstatic.
- Reload the web app.
Refer this step by step article to setup a free account and host web app on pythonanywhere server.
I'm a big fan of Amazon Web Services if you want simplicity and automation. You can create a CodeStar project for Django and Elastic Beanstalk. Everything is set up from you, so as soon as you commit code to your github repo (it even can create the repo for you with the elastic beanstalk config files), it builds, tests, then deploys it.
The best part is you can utilize amazon's free-tier level if you are a new member so it's probably going to be free or extremely cheap.
Look here for reference:
https://aws.amazon.com/codestar/faqs/
digitalocean.com is good for hosting. link
I used this for Django 2.0 with python3.

How To Stop Overwriting Directories When Pushing to Heroku

This seems simple enough but I can't find a fix. I have a django app on heroku. I'm using heroku as a staging environment. My app uses a directory media for images and files uploaded from the admin pages.
When I git push heroku master it destroys this directory even though it's not added in the repo.
How can I stop this?
Heroku doesn't provide persistent storage.
On git push your code is transformed into a slug and then it is distributed to a dyno that your application runs in. See https://devcenter.heroku.com/articles/slug-compiler for details.
If you want persistent storage you should integrate your application with AWS S3 (Simple Storage Service) or some other service.

How should I stage my bitbucket + heroku django app for development and deployment?

How should I stage my bitbucket + heroku django app for development and deployment?
I'm working on a Django App.
I don't want to use github because I want to host have a private repo.
So right now I know how to deploy an app on heroku but how do I do it through bitbucket?
What is this deployment key stuff?
Do I have to reset my git remote origins or something?
Do I deploy with different folders? and commit my source code to different folders?
What happens when I want scale up my development environment to multiple computers?
I know I will be using git to monitor changes to the repo, how should I allow all of them to deploy to heroku?
Thanks
Change your git remote to point to your bitbucket URL, then proceed as normal.
Your remote origin would be the URL to your bitbucket found in settings. Your remote heroku would be pointing to Heroku.
#dan-hoerst's answer is still correct but I wanted to draw attention to heroku's new pipeline feature which lets you handle your staging and production environment better way.
A pipeline is a group of Heroku apps that share the same codebase.
Apps in a pipeline are grouped into “review”, “development”,
“staging”, and “production” stages representing different deployment
steps in a continuous delivery workflow.
You can find more about it here https://devcenter.heroku.com/articles/pipelines