Azure Spring Cloud: A Comprehensive Overview
Learn about Azure Spring Cloud and its main features quickly and with ease in order to build, deploy, scale, and manage your applications in the cloud.
Join the DZone community and get the full member experience.
Join For FreeIn this article, you will learn about Azure Spring Cloud and its main features quickly and with ease, through a very down-to-earth approach.
What Made it Possible
Azure Spring Cloud is the natural consequence of Microsoft getting closer to the Java community over the last few years, on top of the fact that the Java ecosystem has been completely dominated by Spring for a long time now.
We can speculate that such a feat was only achievable thanks to the visionary leadership of Satya Nadella, Microsoft’s CEO, deciding to treat Java as a first-class citizen rather than a nuisance or a competitor.
It’s quite likely that you already noticed this on your own, but if you didn’t, just think about the following:
- The @JavaAtMicrosoft twitter account regularly tweets about all things Java and Microsoft;
- The Microsoft Developer Blogs now include a “Java at Microsoft” section where articles and updates about Java development with Microsoft tools are often published;
- One of the most well-known Microsoft-maintained IDEs, Visual Studio Code, provides guides and extensions specific to Java development;
- Microsoft formally signed the Oracle Contributor Agreement and actively contributes to OpenDJK since 2019.
Microsoft is not only actively engaged in the Java community, but also does extensive usage of Java itself, think about the fact that:
- LinkedIn consists of more than 500 Java microservices;
- Minecraft’s game client is written in Java;
- Yammer’s back-end is written in Java;
- Azure includes several cloud components that can be interacted with through Java applications, and some of these are even specific to Java applications;
- last but not least, Microsoft owns and maintains several Open Source Java projects, such as Spring Cloud Azure, that favor the integration of Java applications and Azure Cloud components!
Given these circumstances and the fact that Spring completely dominates the Java ecosystem, as demonstrated by the JVM Ecosystem Report 2020, it was only a matter of time before Microsoft and VMware would set the past aside and start working together on something that would change the way we build and manage modern applications: Azure Spring Cloud.
Azure Spring Cloud
Azure Spring Cloud is one of the most recent PaaS products available on the Azure Marketplace, as it was announced as generally available for the first time at the SpringOne Platform 2020.
It was built from the joint effort of Microsoft and VMware to provide a seamless development experience when building cloud-native applications relying on Spring Boot, Spring Cloud, and integrating with Azure Cloud components.
Azure Spring Cloud, as a fully-managed Spring Cloud service backed by a fully-managed AKS cluster, provides a truly serverless experience when building, deploying, and managing microservices in the cloud.
Enough with the chatter, let’s dive right in!
Quickstart
NOTE: for the sake of simplicity, we’ll assume that an Azure account with a valid subscription is already available, and the build/dependency management tool of choice is Maven.
Deploying a Spring Boot + Spring Cloud application on Azure Spring Cloud is as easy as it can get:
- Create a new Azure Spring Cloud instance through the Azure Portal
- Download and install the Azure CLI if you haven’t done so already
- Add the Azure Spring Cloud extension by running the following command:
az extension add -n spring-cloud -y
(this may not be necessary anymore depending on your Azure CLI version, since the spring-cloud set of commands has been added to the default Azure CLI commands) - Setup the default values for your resource group and Azure Spring Cloud instance:
az configure --defaults group={resource_group}
+az configure --defaults spring-cloud={asc_instance}
- Include the Azure Spring Cloud Client dependency to your project, possibly in a separate profile to not pollute local development dependencies:
<profiles>
<profile>
<id>cloud</id>
<dependencies>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>spring-cloud-starter-azure-spring-cloud-client</artifactId>
<version>2.2.0</version>
</dependency>
</dependencies>
</profile>
</profiles>
- Build your application, remembering to enable the profile you added in the last step:
mvn clean package -Pcloud
- Create a new Azure Spring Cloud app within your Azure Spring Cloud instance (has to be done only the first time):
az spring-cloud app create -n {my-app}
- Deploy your application to Azure Spring Cloud:
az spring-cloud app deploy -n {my-app}
--jar-path target/my-app.jar
That’s all! In just a matter of a few minutes, with 0 code changes and minimal impact on our project, we have successfully deployed our first application to the fully-managed AKS cluster behind our Azure Spring Cloud instance.
This is already a very positive result, but let’s see what else Azure Spring Cloud has to offer.
Distributed Tracing
Azure Spring Cloud provides distributed tracing capabilities for your application out of the box, relying on Azure Application Insights to build a full-fledged “Application Map” showing how incoming requests flow into our system, how components interact with each other, and keeping track of sampled calls along with data regarding such calls’ outcome and duration.
You can specify a pre-existing Azure Application Insights instance to rely on, otherwise — given the distributed tracing setting is enabled — a new Azure Application Insights instance will be specifically created for usage by Azure Spring Cloud.
Log Storage
One of the most common solutions is to send all of our logs and metrics to an Azure Log Analytics workspace since we can then rely on the powerful Log Analytics Query Language to perform specific and accurate historical checks upon our collected data.
NOTE: a special table called AppPlatformLogsForSpring
is available for queries on Log Analytics. This table contains all the logs from our applications deployed on Azure Spring Cloud.
Log Tailing
Since the Azure Spring Cloud January update, it is now possible to stream logs in real-time to our terminal by running the following command:
xxxxxxxxxx
az spring-cloud app logs --name {app-name} --resource-group {resource-group} --service {asc-instance} -f
This feature doesn’t really need any explanations, but you can imagine how useful it can be when trying to verify our application behavior during development or trying to tackle hard issues in production-like environments.
Monitoring and Alerting
The Azure Spring Cloud January update also added the ability to create alerting rules, which in summary means that in the matter of a few clicks we are able to:
- Pull and analyze metrics from our application;
- Setup a condition that will trigger an alerting action based upon these metrics;
- Define the way through which the alert should be carried out (eg. sending a warning email).
It is quite a wonder to be able to set up such a complex, useful, and often critical feature with so little effort!
Centralized Configuration
When in need of a centralized configuration for our cloud-native applications Spring users most often rely on Spring Cloud Config Server. When working with Azure Spring Cloud we don’t have to build and deploy our own Spring Cloud Config Server but we can simply configure an automatically deployed, fully-managed by Azure Spring Cloud, Spring Cloud Config Server.
Furthermore, the applications that have to contact the Spring Cloud Config Server won’t need any configuration, just the spring-cloud-starter-config
dependency will be more than enough. Azure Spring Cloud will make sure that all the client applications will be automatically configured at deploy time in order to securely connect to the forementioned fully-managed Spring Cloud Config Server. Neat!
Service Discovery
Again, client applications won’t need any configuration in order to interact with the forementioned Spring Cloud Eureka Server, but they will still need to include the spring-cloud-starter-netflix-eureka-client
dependency.
Service Bindings
A quite unique feature of Azure Spring Cloud goes by the name of “service bindings”.
Service Bindings allow applications to interact with Azure Cloud components (such as Azure Cosmos DB, Azure Cache for Redis, Azure Database for MySQL) with no need to provide credentials for the connection to be established. Assuming we created a service binding for our application, the properties that are necessary in order to connect to the matching Azure service will be automatically injected by Azure Spring Cloud at runtime.
Scaling Up
We can easily scale up our Azure Spring Cloud app resources as needed through the Azure Portal or via equivalent Azure CLI commands. Assuming “Standard” tier billing, the maximum amount of vCPUs per application is currently 4, whereas the maximum number of GBs of memory assigned to a specific application is 8.
Scaling Out
Scaling out can similarly be performed manually — through the Azure Portal or equivalent Azure CLI command — , allowing us to specify the total amount of instance replicas that should be present at a specific time, up to 500.
More interestingly, we can choose to scale out applications through an automated process based upon gathering and analyzing metrics in real-time. As seen in the previous “Monitoring and Alerting” section, we can arbitrarily pick any metric and set up a condition that, when satisfied, will trigger the corresponding user-defined scaling-out action (eg. increase the instances count by 1).
Don’t be afraid of autoscaling! Safety nets such as the minimum, maximum, and default amount of instances that should be present for any given application are extremely easy and straightforward to configure.
Availability
Through Azure Spring Cloud we can quite easily achieve minimal downtime. First of all, the “Standard” Azure Spring Cloud tier adheres to Service Level Agreements guaranteeing at least 99.9% availability. Moreover, blue/green deployment can be performed in just a few clicks with Azure Spring Cloud, allowing developers to verify features in a production-like environment, minimize the impact on the end-user, and eliminate downtime when rolling out updates.
Billing
The billing model is of the type “pay-as-you-go”, which is quite convenient as it promotes an economically-optimized scalable and elastic infrastructure for which the user pays solely depending on actual usage.
More in detail, there is a base hourly rate which is valid up to 16 vCPUs and 32 GBs of memory. For each additional vCPU and/or GB of memory used, there is an additional hourly rate to pay on top of the basic one.
Summary of Benefits
Overall, Azure Spring Cloud provides:
- Shorter development cycles, by making it easier to reach production;
- Less infrastructure to manage, allowing developers to care about software rather than Kubernetes clusters;
- Virtually zero downtime, thanks to very satisfying SLAs and ease of applying b/g deployment;
- A secure network, as network management is fully delegated to Microsoft;
- An elastic and scalable infrastructure, paired with a conveniently fitting billing model.
Useful Resources
If you want to get more familiar with Azure Spring Cloud, you can refer to the following:
- Azure Spring Cloud Official Documentation
- Azure Spring Cloud Training
- ‘Bootiful Azure Spring Cloud’ by Josh Long and Julien Dubois(SpringOne Platform 2019)
Conclusion
Azure Spring Cloud is an amazing service to quickly build, deploy, and manage your applications in the cloud with minimal effort and rich features at the same time. It is definitely worth a try, especially if your applications already rely upon the very same tech stack that Azure Spring Cloud has been built to support.
Opinions expressed by DZone contributors are their own.
Comments