Introduction to Azure Spring Cloud + IntelliJ IDEA

This post has been republished via RSS; it originally appeared at: New blog articles in Microsoft Tech Community.

Azure Spring Cloud is a brand-new Platform as a Service offering for Microservices apps. It is a fully managed service jointly built, operated, and supported by Pivotal and Microsoft to simplify spring boot based microservices development and management. We the Java on Azure team are committed to making Microsoft Azure an excellent cloud for Java workloads and are continuing to deliver more per customers’ requests and feedback. In this blog, I will walk you through how you can accelerate your development with Azure Spring Cloud and the Azure toolkit for the famous Java IDE, IntelliJ IDEA.

 

Requirements

 

You will need a few things prepared before following the upcoming sections:

IntelliJ IDEA, Community/Ultimate Edition, version 2020.1/2019.3 installed

An Azure Account

Azure Toolkit for IntelliJ installed and signed-in

An Azure Spring Cloud instance provisioned

 

Prepare your Spring application

 

First, let’s start from the simple sample spring boot project, clone the repo to your local machine, then import the Complete folder with IntelliJ IDEA as a Maven project.

 

git clone https://github.com/spring-guides/gs-spring-boot.git
 

To enable Azure Spring Cloud features like service discovery and so on, a set of dependencies is needed. The Azure Toolkit for IntelliJ will help you on that. Right-click on the project and select Azure -> Add Azure Spring Cloud dependency.

 

add-dependency-2.png

 

You will see a set of dependencies added to your pom.xml. The version is calculated based on existing dependencies in your pom.xml, but feel free to edit them if you know what you are doing. Then, click Import Changes on the bottom right to resolve dependencies automatically.

 

add-dependency-3.png

 

Except the spring-cloud-starter-azure-spring-cloud-client, dependencies added above are not hard requirements. They are recommended to enable full Azure Spring Cloud feature set from Eureka, Config Server to monitoring, distributed tracing and so on. In the end, let’s add the discovery client annotation in your Application.java, and you are all set for an app discoverable for the Eureka server hosted by Azure Spring Cloud.

 

add-annotation.png

 

Deploy your app to Azure Spring Cloud

 

Now, let’s go ahead and deploy the app to Azure Spring Cloud. With the help of Azure Toolkit for IntelliJ IDEA, this will be super easy. Right-click on the project and select Azure -> Deploy to Azure Spring Cloud.

 

deploy.png

 

In the pop-up configuration window, select the right subscription and Azure Spring Cloud instance you have provisioned; create a new app named demo and enable Public Endpoint.

 

deploy-config.png

 

Click Run and you will see the app built and deployed in a few minutes.

 

deploy-log.png

 

Click on the URL printed out and you can access your App now. Congratulations for your first Azure Spring Cloud app deployed from IntelliJ IDEA!

 

access-endpoint.png

 

View your app status and logs

 

To manage your Spring Cloud app, navigate to your Cloud Explore panel on the left and find the app just deployed under Spring Cloud nodes. Right-click on the app, select Show Properties and you will see the tap show up on the right. Here you can perform some most used actions like restart/delete/scale/editing JVM options and environment variables. Take a closer look at the Instances details and you can see that the app now has one instance running and registered to Eureka server since the discover status is UP. For other functionalities, select Open in Portal in the right-click menu to explore more.

 

 

app-properties.png

 

 

It’s also super easy to stream the logs to your IDEA. Right-click on your app in the Cloud Explorer, select Streaming Logs, select the instance in the pop-up windows and then you will see logs showing up soon. For full logs analysis experience, explore Azure Spring Cloud’s seamless integration with Azure Monitor.

 

log-stream.png

 

 

Learn more about Java on Azure

 

If you liked learning more about Java on Azure, Azure Spring Cloud, Azure tools for Java developers, check out the links below!

Java on Azure Developer Center

Azure Spring Cloud Documentation

Azure Tools for Java developers

Don’t forget to follow us on Twitter for more latest Java on Azure posts.

 

Leave a Reply

Your email address will not be published. Required fields are marked *

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.