28
app deployment 26/06/2022 Talentica Software

Django app deployment in Azure By Saurabh Agarwal

Embed Size (px)

DESCRIPTION

How to create and deploy a Django/Python Application in Azure . Presenter Saurabh Agarwal , Talentica software.

Citation preview

Page 1: Django app deployment in Azure By Saurabh Agarwal

app deployment

12/04/2023Talentica Software

Page 2: Django app deployment in Azure By Saurabh Agarwal

04/12/2023 Talentica Software

Heard of MVC ?...• Models• Views• Controllers

Page 3: Django app deployment in Azure By Saurabh Agarwal

04/12/2023 Talentica Software

DJANGO ARCHITECTUREDjango instead uses a similar MTV pattern .

ModelsTemplatesViews

But this is just naming convention and is pretty much the MVC pattern.

Page 4: Django app deployment in Azure By Saurabh Agarwal

04/12/2023 Talentica Software

Page 5: Django app deployment in Azure By Saurabh Agarwal

04/12/2023 Talentica Software

DJANGO PROJECT STRUCTUREdjango-admin.py startproject helloworld helloworld/manage.py helloworld/__init__.py settings.py urls.py wsgi.py• python manage.py startapp polls polls/ __init__.py

admin.py models.py tests.py views.py

Page 6: Django app deployment in Azure By Saurabh Agarwal

Talentica Software

3 options …

Virtual MachineWeb SitesCloud Services

12/04/2023

Page 7: Django app deployment in Azure By Saurabh Agarwal

Talentica Software

Virtual MachineWe can deploy the django app in any VM .We will create a Ubuntu(Linux) vm and

deploy django app there .

12/04/2023

Page 8: Django app deployment in Azure By Saurabh Agarwal

Talentica Software

Creating and setup the Linux VM on Windows Azure (from gallery)

12/04/2023

Page 9: Django app deployment in Azure By Saurabh Agarwal

Talentica Software12/04/2023

Page 10: Django app deployment in Azure By Saurabh Agarwal

Talentica Software12/04/2023

Page 11: Django app deployment in Azure By Saurabh Agarwal

Talentica Software

Once it is ready, click to open the VM management, and go to Endpoints. Click Add Enpoints in the command bar at the bottom, and open the port 80 for your VM

12/04/2023

Page 12: Django app deployment in Azure By Saurabh Agarwal

Talentica Software

SSH using Putty Download putty if you haven’t. Open Putty and connect to your Linux VM using your VM url, and SSH port.

12/04/2023

Page 13: Django app deployment in Azure By Saurabh Agarwal

Talentica Software

Once you are login, enter the following commands to install Python, Django and Apache server. The Python Package Index is a repository of software for the Python programming language sudo apt-get install python-setuptools

sudo easy_install djangosudo apt-get install apache2 libapache2-mod-wsgi

Nano views.py

Nano urls.py

12/04/2023

Page 14: Django app deployment in Azure By Saurabh Agarwal

Talentica Software

Now open up your apache default config file using nanosudo nano /etc/apache2/httpd.conf

Insert these the two lines to the top of the file

WSGIScriptAlias / /home/azureuser/back-end/trainerplus/wsgi.py WSGIPythonPath /home/azureuser/back-end

<Directory /home/azureuser/back-end/trainerplus> <Files wsgi.py> Order deny,allow Allow from all </Files> </Directory>

sudo apachectl restart

12/04/2023

Page 15: Django app deployment in Azure By Saurabh Agarwal

Talentica Software

Azure WebsitesTo publish Websites and Cloud Services ,

we need Python Tools 2.0 for Visual StudioPython 2.7 (32-bit)Visual Studio and Windows Azure SDK:

VS 2010 Pro or higher with Windows Azure SDK 2.1VS 2012 Pro or higher with Windows Azure SDK 2.1, 2.2

or laterVS 2013 Pro or higher with Windows Azure SDK 2.2 or

later

12/04/2023

Page 16: Django app deployment in Azure By Saurabh Agarwal

Talentica Software

Creating a Project

12/04/2023

Page 17: Django app deployment in Azure By Saurabh Agarwal

Talentica Software

Creating a Virtual Environment

Page 18: Django app deployment in Azure By Saurabh Agarwal

Talentica Software

Azure Websites Download the publishing profile .

12/04/2023

Page 19: Django app deployment in Azure By Saurabh Agarwal

Talentica Software

In Visual Studio, right-click on the project node and select Publish.

Import the web site publish profile file you downloaded previously. Accept the defaults and click Publish to initiate the publishing. When publishing has completed, a web browser will open to the published web site.

12/04/2023

Page 20: Django app deployment in Azure By Saurabh Agarwal

Talentica Software12/04/2023

Page 21: Django app deployment in Azure By Saurabh Agarwal

Talentica Software

Azure Cloud Service

Right-click on the project node and select Add Windows Azure Cloud Service Project or Convert →Convert to Windows Azure Cloud Service Project (you'll see one or the other, depending on your version of Visual Studio). This will add a new project to the solution, with the .Azure suffix. This new project is marked as the startup project in the solution

12/04/2023

Page 22: Django app deployment in Azure By Saurabh Agarwal

Talentica Software12/04/2023

Page 23: Django app deployment in Azure By Saurabh Agarwal

Talentica Software12/04/2023

Page 24: Django app deployment in Azure By Saurabh Agarwal

Talentica Software12/04/2023

Page 25: Django app deployment in Azure By Saurabh Agarwal

Talentica Software12/04/2023

Page 26: Django app deployment in Azure By Saurabh Agarwal

Talentica Software

What to choose???Windows Azure Web Sites are ideal for…

Windows Azure Web Roles are ideal for...

Windows Azure Virtual Machines are ideal for...

Modern Web Apps Applications that consist of client-side markup and scripting and/or server-side scripting and a database. You can scale out or up as needed.Also the web tier of multi-tier applications.

Multi-tier Applications Applications that are composed of multiple tiers, each of which can be scaled independently (i.e. asynchronous background processing, like order processing) using both Web and Worker Roles.Note: Web Sites can also be used for the web tier.

Server Applications Existing applications that leverage SQL Server, MySQL, MongoDB, Sharepoint Server, etc.

Continuous Development Deploy directly from your source code repository using Git or Team Foundation Service.

Apps that require advanced administration Applications that require admin access, remote desktop access, or running code with elevated privileges.

Existing line-of-business apps Choose an image from the gallery or upload your own VHD.

Popular Open Source Apps Launch a site with a few clicks using apps like WordPress, Joomla!, and Drupal.

Apps that require advanced networking Applications that require network isolation with Windows Azure Connect or Windows Azure Virtual Network.

Windows or Linux Support for Windows Server and community/commercial versions of Linux. Connect VMs with Cloud Services to take advantage of PaaS services.

Page 27: Django app deployment in Azure By Saurabh Agarwal

Talentica Software

(Web Sites vs Web Roles) Feature breakdown…Feature Web Sites Web Roles

Access to services like Caching, Service Bus, Storage, SQL Azure Database Yes Yes

Support for ASP.NET, classic ASP, Node.js, PHP Yes Yes

Shared content and configuration Yes No

Deploy code with GIT, FTP Yes No

Near-instant deployment Yes No

Integrated MySQL-as-a-service support Yes Yes*

Multiple deployment environments (production and staging) No Yes

Network isolation No Yes

Remote desktop access to servers No Yes

Ability to run programs with elevated permissions No Yes

Ability to define/execute start-up tasks No Yes

Ability to use unsupported frameworks or libraries No Yes

Support for Windows Azure Connect/ Windows Azure Network No Yes