Azure Spring Cloud is a new Platform as a Service offering for Microservices apps. It is a fully managed service jointly built, operated, and supported by VMware and Microsoft to simplify spring boot based microservices development and management. In this blog, we will walk through how you can accelerate your development with Azure Spring Cloud and IntelliJ IDEA.
You will need a few things prepared before following the upcoming sections:
git clone [email protected]:spring-guides/gs-spring-boot.git
And import the final form of the project, contained in the
complete subfolder of that clone:
To enable Azure Spring Cloud features (discovery service, config server, etc) a set of dependencies is needed. The Azure Toolkit for IntelliJ will help with that. Right-click on the project and select Azure → Add Azure Spring Cloud dependency:
A set of dependencies will be added to the
pom.xml. The version is calculated based on existing dependencies in the pom, 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.
spring-cloud-starter-azure-spring-cloud-client, the dependencies added are not hard requirements. They are recommended to enable the full Azure Spring Cloud feature set including Eureka, Config Server, monitoring, distributed tracing, etc. Let’s add the discovery client annotation in your
Application.java, so that the application will be discoverable via a Eureka server once deployed 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.
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.
Click Run and you will see the app built and deployed in a few minutes.
The application should immediately be accessible via the URL printed to the console. Congratulations for your first Azure Spring Cloud app deployed from IntelliJ IDEA!
To manage your Spring Cloud app, navigate to your Azure Explorer 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 common actions like restart/delete/scale/editing JVM options and modifying 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 further operations, select Open in Portal in the right-click menu to explore more.
It’s also super easy to stream the logs to your IDEA. Right-click on your app in the explorer, select Streaming Logs, select the instance in the pop-up windows and then you will see logs showing up soon. For a full logs analysis experience, explore Azure Spring Cloud’s seamless integration with Azure Monitor.