OrionLab

Sign in

We will deploy a ‘helloworld’ Django application that we created in our previous article Create a Django ‘helloworld’ application using Visual Studio Code in an Azure App Services. This will give us an overview on how deploy a Django web application to a Serverless Azure App Services.

Serverless app services gives us an advantage on effortless Continuous Deployment as well as Management of your Infrastructure for your application. …


We will create and deploy a basic ‘helloworld’ Django application today in Azure App Services. This will give us an overview on how deploy a Django web application to a Serverless Azure App Services.

Serverless app services gives us an advantage on effortless Continuous Deployment as well as Management of your Infrastructure for your application. Another advantage is, in-case of any failures, Azure in-built features like Application Insights, Azure Monitor, for security Azure DDoS Protection Plan as well as Azure Defender, Azure Security Center will take care for your application security.

Pre-Requisite —

1. Python — Install Python in your…


  1. Login to Azure Portal and on the top search in portal, search for Azure App Services. Select that and Click on “Create App Services”.
Create App Service in Azure Portal — Create an Azure App Service with GitHub Continuous Deployment Integration. | Orionlab | Orionlab.io
Create App Service in Azure Portal

2. Inside the Basic Tab, Choose Subscription, Resource Group. Enter Instance Details as —

2.1) Name — Enter the global unique name as it will be concatenated with .database.windows.net as uniquename.azurewebsites.net.
2.2) Publish — Select as either “Code” or “Docker Container”. Here we are selecting it as Code.
2.3) Runtime Stack — We can choose them from Node -versions, Python -versions, etc. For Deploying Django we will use Python 3.6.
2.4) Operating System — We Have “Linux” and “Windows”…


  1. Login to Azure Portal and on the top search in portal search for Azure SQL. Select that and Click on “Create Azure SQL resource”.
Click on Create Azure SQL Resource — Setup Azure SQL within Python-Django deployed in Azure App Service | Orionlab | Orionlab.io
Click on Create Azure SQL Resource

2. Select for SQL Database for Hyperscale and Serverless Options. We usually use SQL managed instances and SQL Virtual Machines for Migration movements.
Select Resource Type as
Single Database for Test, POC or less data. For Production choose Elastic pool.

NOTE : Database Servers are for Creating Database server and then adding databases Instances in it


Create Inventory

Login to Ansible Tower and on the left blade Select Inventory. To Create a New Inventory click on [+] symbol as highlighted.

Ansible Tower — Inventory Section — Create and Synchronize Microsoft Azure Inventory with Ansible Tower | Orionlab | Orionlab.io
Ansible Tower — Inventory Section

Select Inventory from the Option.


Ansible Playbook

Note: Replace template.json & parameter.json with location of each file. You can save them in GitHub, Azure Repos, any Storage Accounts like Azure Blob, Amazon S3 etc.

---
- hosts: localhost
become_user: awx
vars:
resource_group: sampleresourcegroup-rg
location: westus2
tasks:
- name: Creating Virtual Machine
azure_rm_deployment:
resource_group: "{{ resource_group }}"
location: westus2
name: devus3apo01
template: "{{ lookup('file', 'template.json') }}"
parameters: "{{ (lookup('file', 'parameter.json') | from_json).parameters }}"

Define resource_group and location in Ansible Tower Extra Variables Section with your specific.

Ansible Tower

Ansible Tower — Create Azure Virtual machine

Create Job Template, add -

1. Name,
2. description,
3. Job Type- Run,
4. Inventory — inventory01,
5. Project — Project Name…


Ansible Playbook

---
- hosts: localhost
become_user: awx
vars:
resource_group: sampleresourcegroup-rg
location: westus2
storage_name: samplestorageaccount09777

tasks:
- name: create an Storage account
azure_rm_storageaccount:
resource_group: "{{ resource_group }}"
location: "{{ location }}"
name: "{{ storage_name }}"
type: Standard_LRS
kind: StorageV2
access_tier: Cool

Define resource_group, storage_name and location in Ansible Tower Extra Variables Section with your specific.

Ansible Tower

Ansible Tower — Create Storage Account

Create Job Template, add -

1. Name,
2. description,
3. Job Type- Run,
4. Inventory — inventory01,
5. Project — Project001,
6. choose Playbook — Storage Account/create_storage_account.yml,
7. Credentials —
1. Microsoft Azure Resource Manager Key
8. Forks — 0
9. Limit — <Empty>
10. Verbosity — 0 (Normal)
11…


Ansible Playbook

---
- hosts: localhost
become_user: awx
vars:
resource_group: sample-rg
location: westus2
tasks:
- azure_rm_securitygroup:
resource_group: "{{ resource_group }}"
name: sample_nsg
rules:
- name: SSH
priority: 100
protocol: Tcp
access: Allow
direction: Inbound
source_address_prefix: "*"
source_port_range: "*"
destination_address_prefix: "*"
destination_port_range: 22
- name: PythonServer
priority: 101
protocol: Tcp
access: Allow
direction: Inbound
source_address_prefix: "*"
source_port_range: "*"
destination_address_prefix: "*"
destination_port_range: 3200-3201
- name: Gateway1
priority: 102
protocol: Tcp…

Ansible Playbook

Note : Create Network Security Group before Associating the Network Security Groups with Subnets

---
- hosts: localhost
become_user: awx
vars:
resource_group: samplewus2dv1-rg
location: westus2
vnet_name: samplewus2dv1-vnet
tasks:
- name: Create a virtual network
azure_rm_virtualnetwork:
name: "{{ vnet_name }}"
resource_group: "{{ resource_group }}"
address_prefixes_cidr:
- 10.180.134.0/24

- name: Create a subnet samplewus2dv1app-sn
azure_rm_subnet:
name: samplewus2dv1app-sn
virtual_network_name: "{{ vnet_name }}"
resource_group: "{{ resource_group }}"
address_prefix_cidr: 10.180.134.0/26
security_group:
name: samplewus2dv1app_nsg
resource_group: "{{ resource_group }}"
- name: Create a subnet samplelwus2dv1db-sn
azure_rm_subnet:
name: samplewus2dv1db-sn…

Ansible Playbook

---
- hosts: localhost
become_user: awx
vars:
resource_group: sampleresourcegroup-rg
location: westus2

tasks:
- name: Create resource group
azure_rm_resourcegroup:
name: "{{ resource_group }}"
location: "{{ location }}"

Define resource_group and location in Ansible Tower Extra Variables Section with your specific.

Ansible Tower — Templates for Creating Resource Group

Create Job Template, add

1. Name,
2. description,
3. Job Type- Run,
4. Inventory — sapglobal-inventory01,
5. Project — Align Technology CLIP DV01 Environment,
6. choose Playbook — Resource Group/create_resource_group.yml,
7. Credentials — Microsoft Azure Resource Manager Key
8. Forks — 0
9. Limit — <Empty>
10. Verbosity — 0 (Normal)
11. Job Tags — <Empty>
12. Skip Tags — <Empty>
13. Labels — <Empty>
14. Instance…

OrionLab

Orionlab is a professional services company, Experts in Cloud Adoption Strategy Designing and Automation with their patented revolutionary tool — Cloudhive

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store