Friday, December 27, 2024
Google search engine
HomeLanguagesJavaDeploying Spring Boot Application with MySQL Database on Azure

Deploying Spring Boot Application with MySQL Database on Azure

Azure is Microsoft’s cloud platform, just like Google has its Google Cloud and Amazon has its Amazon Web Service or AWS.000. Generally, it is a platform through which we can use Microsoft’s resources. Cloud Deployment is gaining huge traction nowadays as users love the concept of Cloud over on-premise infrastructure. This article gives a lucid explanation of how to deploy a spring boot application with a MySQL database on the Azure cloud platform. Let us see how to deploy Spring Boot application with MySQL database on Azure:

  1. Start with deploying the MySQL database on Azure
  2. Getting ready with MySQL connections
  3. Configuring the Spring Boot application for deployment

Illustration:

In order o set up a huge server, we will require huge investment, effort, physical space, and so on. In such situations, Microsoft Azure comes to our rescue. It will provide us with virtual machines, fast processing of data, analytical and monitoring tools, and so on to make our work simpler. The pricing of Azure is also simpler and cost-effective. Popularly termed as “Pay As You Go”, which means how much you use, pay only for that.

Now we will be discussing steps to detail as follows in a sequential manner in order to get the application deployed on Azure which is as follows:

Step 1: Starting with deploying the MySQL database on Azure 

1.1: Search for MySQL Server on Azure create a resource section.

1.2: Click creates a resource after providing some basic details like the zone and choosing a plan of your choice.

1.3: Once the resource creation is done go to your dashboard and open the resource to view its details.

1.4: Click on Connection security and add the current IP address.

1.5: Click on Connection String and copy the JDBC connection string and store it for the meantime.

1.6: Open MySQL Workbench in your local system. 

1.7: Click on the ‘+’ next to MySQL connections.

Step 2: Getting ready with MySQL connections 

2.1: A dialog will open where give a connection name of your choice, provide the hostname as the server name present in the overview section of the Azure MySQL database. Finally, put the username and password which was generated at the time of resource creation.

2.2: After successfully validating the details click on test connection, and if everything is perfect, then login to the workbench using the above-entered username and password.

2.3: Create a database of your choice using the command ‘create database “name”‘, the execute ‘use database “name” ‘.

Step 3: Configuring the Spring Boot application for deployment

3.1: Open ‘application.properties’ file.

3.2: Add the following properties in it as provided below

server.port= 8080 spring.datasource.driver-class-name =com.mysql.jdbc.Driver spring.datasource.url=jdbc:mysql://[server-name]:3306/[database-name]?useSSL=true spring.datasource.username=[username] spring.datasource.password=[password] spring.jpa.show-sql: true spring.jpa.hibernate.ddl-auto=update spring.jpa.database-platform=org.hibernate.dialect.MySQL5InnoDBDialect  

3.3: Now run the application as a Spring-Boot app. Upon running hibernate automatically configures the table structure for your project on the Azure MySQL database.

3.4: Create an app service on Azure.

3.5: Connect your Git-hub account as an organization, and provide Azure the access rights for the repository containing the code for the current application.

3.6: Finally hit the create button. 

These steps can be used to deploy a Spring Boot app with MySQL database on the Azure cloud platform.

Note: To see the deployment cycle go to the Actions tab of your Git-hub account and you will find the aforementioned actions in progress. Finally, if the application is error-free then a deployment link will be generated. 

Dominic Rubhabha-Wardslaus
Dominic Rubhabha-Wardslaushttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Recent Comments