This article was published as a part of the Data Science Blogathon.
In today’s era, Cloud Computing has become a basic need for every startup or business. Now, developers can quickly develop their applications in the cloud and present them to the end users. Below are some benefits of cloud computing:
1. Hardware Security: It takes backup of all your data in several networks. So your data remains safe in case of hardware failure or power loss.
2. Scalability: Developers can scale up or down the application’s resources based on the fluctuating workloads.
3. Convenience: It enables remote user access, i.e., multiple people can remotely access the server and work on it. It saves time and resources for the companies.
4. Payment Mode: You can access various types of hardware like Virtual Machines, Kubernetes Engine, and Databases. Also, you can customize these services according to your requirements. You have to pay only for your services and how long you have taken.
Below are some more benefits of cloud computing:
Now, let us talk about a famous cloud computing service Microsoft Azure. It is a public cloud computing platform that provides various services like Compute Engine, Storage, Networking, etc.
This tutorial talks about creating a Web App at Azure, and then we deploy web applications on it. I will show you how can deploy a Django Web Application on this Web App.
We will start everything from the very basics. You can also read this article even if you don’t have any prior knowledge of the Azure Platform.
1. You must have an active paid account on Azure, as most are paid services. If you are a college or university student, you can check my article on creating a free student account on Azure without a Credit or Debit card.
2. Basic knowledge of developing web applications.
3. GitHub link for the code used in this tutorial: link
Let’s get started, 😉
1. Open the Azure Portal
2. Navigate to App Services.
3. Click on +Create.
4. Fill up the below configurations according to your requirement:
5. Select the CPU and RAM Configurations
Select the configurations of your CPU and RAM according to your budget and requirements. We have chosen a free tier plan that provides one Gb of memory.
6. Finally, click on Create Button. After creating the app, we will set up the Deployment and Networking part.
7. Access the web app using your domain name
When you hit your domain name, a sample static page is displayed, as no deployed app is currently on it.
Below is the code for the sample Django Application we will use to deploy in this tutorial. You can use your application also if you have any.
Fork this repo into your GitHub account.
It is a simple web-based application made in Django REST Framework and performs basic CRUD Operations.
Our azure web app is now created, and in this section, we will set up the application’s environment variables.
Environment Variables are the variables used to set the configurations of your program and affect how it runs. These variables are written outside of your main program. For ex-, We can store the Secret API Key or some variables that can connect your app with some other 3rd party services.
1. Navigate to Configuration
2. Click on +New application setting
Enter the key and value of the environment variables that you want to use in your app.
But for the sample code, we will store the Django Secret Key and DEBUG status as Envy Variables. Debug status is used to check whether our application is in development mode or production mode.
SECRET_KEY=django-insecure-=wez=%szc194fukmp&l@ql$tyq(pb#)yh58k(e*#$831%kudli DEBUG=True
This section will discuss the deployment of our application using GitHub.
Note:
a) “requirements.txt” must be present in your directory, which contains information on all the libraries and dependencies used in your application. Otherwise, you will get an error during deployment.
b) You must add the domain name in the ALLOWED_HOSTS of your Settings.py file on Django. Or you can select the ALLOWED_HOSTS as “*” to allow all the incoming host names.
$ ALLOWED_HOSTS = ['*']
1. Navigate to Deployment Center
2. Go to Settings, and in Source, select GitHub
3. Authorize your GitHub account and select the Repository and Branch you want to deploy.
You can also check the Workflow Configurations, which contains all the step-by-step commands Azure runs to deploy your applications.
Finally, click on Save.
4. You can also check the logs of your application. If any errors occur during the deployment will show here.
5. After the successful deployment, access your webpage through your domain name.
Sample Deployed Application – https://aryanapp.azurewebsites.net
Congrats ✌, we have deployed our application successfully.
We successfully created a Web App at Microsoft Azure and deployed a sample Django application on it. Other than Django, NodeJS or Microsoft NET Framework applications can also be hosted on this web app. You have to change the runtime stack accordingly while creating your web app. Like we have chosen Python 3.9 for Django.
Currently, Microsoft Azure has provided you with a .NET domain name. But you can also change that domain to a custom .com or .in domain name and get a valid SSL certificate. Scaling up or down your application according to the traffic is also present. There are various more services which you can explore on your own.
Key takeaways of this article:
1. Firstly, we have discussed Cloud Computing and its benefits.
2. Then, we set up a Web App at Microsoft Azure.
3. We have created the Environment Variables used in the sample application.
4. Finally, we have deployed the Django application on a live server.
It is all for today. I hope you have enjoyed the article. You can also connect with me on LinkedIn.
Do check my other articles also.
The media shown in this article is not owned by Analytics Vidhya and is used at the Author’s discretion.