Setup MySQL and Service Deployment in Azure Cloud Services.

Mohamed Thasneem
5 min readAug 24, 2020

--

Hello there, In my previous article Full Stack Application Deployment in Azure I have given the overview of my application to deploy in Azure. So in this article, we will see how to deploy our Permanent-Product Service in Azure.

Setting up a MySQL server in Azure

Select Azure Database for MySQL in the Databases category whish is in the Microsoft Azure Portal. And create the new MySQL server.

need some configuration.

  • Resource Group- Select/Create a new Resource Group.
  • Server name- Give a unique name for your MySQL server.
  • Location- Select a region in which you need to spin up the server.
  • Compute Storage- Select the storage based on your application’s need and also keep a look at the costing as well.
  • Then give an Admin username and password to access the database server.

Then Click Review and Create.

So now we have created our Azure My SQL database server. Now in the portal, we can see that our MySQL is up and running. So next will see how to create the database using the created database server.

To access the database server we need to set up the firewall. To access from your MySQL Workbench then give your machine IP. You can set up your firewall for specific IP’s that need to access your server. Also, we are accessing the database server from Azure App Service, so we need to allow access to Azure services as well.

Go to the Connection Security and click on Add current client IP to access the database server from our local machine. Also, enable YES to Allow access to Azure services, then only we can connect from Permanent-Product Service to access the Database.

Then open your MySQL workbench from your machine and create a New Connection.

Add your server name, username and login to the server using the password of the created server.

Then create the database using the SQL command.

create database demo_db;

So now we have created a database in the Azure MySQL server. So next will see the steps to deploy the Permanent-Product Service.

So Let’s Start to Deploy !!!

Go to my Github repository and clone/download my project.

From the root directory move to /backend module in which our Back End Service resides.

Go to the application.properties file and change the following database configurations with the MySQL server you have created.

We will build the Permanent-Product JAR and deploy it to Azure App Service. So Open the Permanent-Product pom.xml and add the following maven dependency.

<plugin>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-webapp-maven-plugin</artifactId>
<version>1.9.1</version>
</plugin>

We are deploying the JAR using Azure CLI, So if you don’t have Azure CLI installed then install it. Look Azure Cli installation here

Open Azure CLI and first login to the CLI using the following command and it will prompt to the Azure login page in a browser. ( Open CMD in backend folder ).

az login

Provide your Azure account login credentials and log in. After a successful login you would see

Then to add the deployment configurations run the following code

After the Successful Build, the configurations will be added to your pom.xml. You can change the configurations from your pom.xml. You can change the appName, pricing tier, location etc as per your need. Also, add this app setting to your configuration as well.

<appSettings> 
<property>
<name>JAVA_OPTS</name>
<value>-Dserver.port=80</value>
</property>
</appSettings>
<pricingTier>F1</pricingTier>
<region>westeurope</region>

And Make sure pricing tier is in F1 ( for free ).

Then to deploy your app in Azure App Service first clean and then deploy.

mvn clean package
mvn azure-webapp:deploy

So now we have deployed our backend in Azure App Service. So in the Azure App Services, we can view the deployed service.

So now it’s all done!!!. Let’s test our deployment of backend Service using the PostMan.

  • Add an Employee - POST: /employeelist
  • View all Employee— GET: /addemployee
  • Delete an Employee — DELETE: /employeelist/{empId}

So that’s it we have set up the MySQL server and deployed our Permanent Product Service in Azure. So next we will see how to deploy Message-Service in Azure Function.

Next Article :- Creating and Deploying App Function in Azure Cloud Services

Thank You!

--

--

No responses yet