Azure Spring Cloud: A Comprehensive Overview

In 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.

Its quite likely that you already noticed this on your own, but if you didn’t, just think about the following:

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!
6 out of 10 developers depend upon Spring for their applications!

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

Example of an Application Map on Azure Application Insights

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

Example of a Diagnostics Setting redirecting logs and metrics to Log Analytics

Azure Spring Cloud offers logs/metrics collection and storage relying on either of Log Analytics, Azure Storage, or Azure Event Hubs. This feature can be enabled by heading to the “Diagnostics Setting” section and specifying which kind of logs and metrics should be stored, on top of the way that will be used to store them.

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:

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 & Alerting

https://devblogs.microsoft.com/java/whats-new-in-azure-spring-cloud-jan-update/

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.

Example of a fully-managed Spring Cloud Config Server’s configuration

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

An application correctly registering itself inside the fully-managed service registry

A solution very similar to the one employed for centralized configuration has been applied to provide service discovery out of the box: a fully-managed Spring Cloud Eureka Server is running at all times behind the curtains, allowing clients to register themselves inside its service registry.

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

Setup of an Azure Cosmos DB binding

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

Manually scaling out an application on Azure Spring Cloud

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.

Scale out an application whenever the CPU average usage is ≥ 70% for 10m+

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 & 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).

Setting minimum, maximum, and default autoscaling limits

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

Switching staging and production deployments around in just a few clicks

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.

“Standard” tier billing explained

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:

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.

If you liked what you just read, please remember to follow me on Medium and Twitter for more articles like this. I’d really appreciate it ;-)

Software Developer @ https://www.linkedin.com/in/dsibilio/ — If my articles helped you, consider buying me a coffee :) https://www.buymeacoffee.com/dsibilio

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store