Distributed and Cloud Computing
With Azure cloud platform
This article is written as a requirement for course SENG 41283 : Distributed and Cloud Computing. And the web application used in here is a sample web application built using html, css, js and php.
Further here I have used Microsoft azure dev tool which has cloud computing facilities.
How to create an Azure account?
First you have to go to the azure signup and create an azure account.
After creating the account providing the relevant details you can get $200 free azure subscription for a month. We can spend this $ amount for our resources.
Then you have to sign in to the azure portal providing the username and password.
Sign in.. and then you will be directed to the following page.
Now we are done with creating the azure account.
First we must create a resource group. This holds the all the services that we are going to implement and manage them as a group. When we create each service we need to select this research group so to create that service under that resource group. There are many services associated with resource groups like App services,Front doors, Azure Database for MySQL servers, Azure Active Directory, bot services, service hub connectors etc. We use different resources to implement the project. Resources are instances of services that you create, like virtual machines, storage, or SQL databases.
In this implementation I am going to use App services,Front doors, Azure Database for MySQL servers, Azure Active Directory etc. Let’s look into one by one with their implementation.
My resource group : saloncilendri
Azure App Service is a HTTP based service which provides the capability to host web applications, mobile applications back ends, rest APIs etc. We can select the language we are using. Here my application is a php web application. Apart to that you can use languages like .NET, .NET Core, Java, Ruby, Node.js, Python.
Features of app service
- Multiple languages and frameworks
- Global scale with high availability
- Security and compliance
- Managed production environment etc.
In my application I created a App service named as webservercilendri. When creating it, I selected my resource group as the resource group, runtime stack -> php, OS-> windows. Then go to the monitoring tab and check whether you have chosen enable app insight. From that you can see the CPU allocation, requests etc.
After creating the app service we need to deploy our web app in the azure app service. For that I did a manual deployment using an FTP connection. There are few other ways that you can use to do this. You can do this with continuous integration with a git repo or with Bigbucket etc.
Select the app service, go to deployment center and select FTP dashboard. There you will find FTPS end point, user name and password.
These details can be used in file transfer tools. I have used WinSCP in this example. Open WinSCP after installing it and provide necessary details of the app service.
You can simply use drag and drop with this tool. Take the folders of your application from the local environment and drag it into the remote environment.
After transferring all the files go to the configuration -> default documents and add your web application home page to it. In my case home.php.
Now you can access your web page using the url which is given in the overview page.
Now we are done with deploying app service. Let’s move to deploy our database.
Azure database for mysql server is really easy to setup, extend and manage. It also provides high availability. My web application has a database consist of two tables.
First we need to create Azure database for mysql resource under the saloncilendri resource group.
My azure database for mysql : saloncilendridb.
After creating the database, first we need to configure the firewall.
Go to the connection security tab in the created database service.
There you have to disable the SSL Connection and should give an IP address range where you provide access to this. By default azure rejects all the IP addresses through the firewall. So we need to add client machines IP addresses. Here I have given 0.0.0.0 — 255.255.255.255 range.
After configuring the firewall settings, download and open heidiSQL — tool that we are using to create our db in the cloud.
Provide the username and password of your database.
Here I am using a database which I created and exported from phpmyAdmin named — cilendri.
First need to create a new database using heidisql.
After creating the database we can import out tables to it.
Now our database exists in the cloud. Then we need to connect the database with the web application.
To make the connection between the database and the application, we need the connection string relevant to the application. As my example project is a php project , I took the php connection string.
Navigate to connection strings in the database resource. Copy the relevant string.
We need to change the password and database name that we have given while creating the database and need to copy this string in our php file where we make a connection to the database.
mysqli_ssl_set($con, NULL, NULL, “abcd.pem”, NULL, NULL);
mysqli_real_connect($conn, “saloncilendridb.mysql.database.azure.com”, “saloncilendri@saloncilendridb”, “*******”, “cilendri” , 3306);
mysqli_ssl_set($con, NULL, NULL, “abcd.pem”, NULL, NULL);
In the above code line abcd.pem is the name of the SSL certificate which I downloaded and placed in the web app. So you can enable the SSL.
With that we finished connecting our web application with the database. So let’s move to the next service.
Azure Active Directory
Azure Active Directory is an Identity and Access Management (IAM) service which is used to control the access to the application. We can use Azure AD to control access to your apps and your app resources, based on your business requirements.
In my web application Admin can log in to his profile to view upcoming bookings.
When the admin logs in, he should be directed to Microsoft account logging and select the user email.
And when click on logout button should be logged out from the account.
To do this first we need to register our account in new registration, App registration in Azure Active Directory service.
Then need to configure Redirect URI, Logout URL and SelectID tokens.