Build enterprise Java code with Azure Spring Cloud
There is still a lot of Java applications out there that power our businesses. But what happens when we move those Java applications to the public cloud? Can we deploy them without rewriting them and still have all the cost and scaling advantages of services like Azure?
One option is Azure’s new Spring Cloud service. Built around the popular Spring Boot Java framework from Pivotal, it helps you take advantage of key Azure services in your Java code and use Azure’s Kubernetes Service to manage scaling. There’s very little configuration needed, and even less platform management, as it’s available as a managed service. Currently in private preview, a public preview is due before the end of 2019.
A derivative of the familiar Spring, Spring Boot is perhaps best thought of as an effective run time for enterprise Java applications. All you need to do is write and deploy your code. Spring Boot configures and manages libraries and services for you. The intent is that your code, as the Spring Boot documentation says, “just runs.”
Opinionated Java on Azure
It’s Spring Boot’s opinionated approach to handling dependencies that makes it suitable for running as a managed cloud service. If you don’t need to manage the libraries your code needs, it’s a lot easier to keep services up to date, and to ensure that you can build your application code and any associated artifacts into a continuous delivery pipeline. Any changes simply generate and deploy a new JAR (Java Archive). Pivotal’s Spring Boot tooling includes its own Build Service, which takes your code, compiles it, packages it, and, in Azure Spring Cloud, delivers it in a container ready to run on Azure Kubernetes Service (AKS). Once code has been deployed to Azure, you can use the Azure CLI to run and scale your applications.
Pivotal has been working with Heroku to develop tools to improve creating containers for Kubernetes applications, as part of its Build Service. If you’re using Azure Spring Boot, you’ll use these tools to manage your application images. One tool, Cloud Native Buildpacks, is used to construct and package your application images, allowing them to run anywhere Spring Boot runs. The other, kpack, works with Kubernetes controllers to automate deployments using the Kubernetes command line and a set of custom Kubernetes controllers.
With kpack in Spring Boot, if you push an update to your source control tree, kpack can detect the push and automatically build and deploy an updated Buildpack to your application. It’s not only for Spring Boot, it’s also suitable for use with Cloud Foundry applications and since it’s open source, it’s being picked up by other Kubernetes-based projects. In Azure Spring Boot it automates working with your code and creating and updating containers, ready for deployment.
Quick Azure integration with Spring Boot Starters
One of the key Azure Spring Boot features is its selection of Starters, which gives you access to various service APIs from your code, taking advantage of its automated support for essential libraries. Azure Spring Cloud adds Starters for key Azure services, including its core databases (Azure SQL and Cosmos DB), for Azure Active Directory, and for streaming data with Event Hubs. You can even use it in conjunction with Azure’s own monitoring tools, allowing you to integrate a Spring Boot application into a wider portfolio of Azure services with end-to-end performance monitoring and traceability.
The Starters add new properties and dependencies to the various Spring Boot configuration files, importing the appropriate modules as it’s deployed. You don’t need to have your Azure resources in the same Resource Group as your Spring Boot application since you separately configure the application properties for your code with details of your resource account, including any credential files used to store authentication keys. Once you’ve completed your Azure configuration, you can add the appropriate code to your application. As Spring Boot manages the connection to Azure resources, you can use them as if they were native Spring Boot resources, with no need to add Azure-specific code to your application.
By separating Azure services from code, you make your application portable, able to run anywhere that you’ve got a Spring Boot instance. A storage blob on Azure is the same as a storage blob on your own servers, as is a database or an authentication service. There’s no need for your developers to have Azure-specific skills; they can carry on with their existing Java knowledge.
You’re not limited to using Spring Boot as a managed service. Azure supports your own Spring Boot instances, using virtual machines to host your servers. However, you’re then responsible for ensuring your applications and the underlying framework are up to date. With a managed service from Microsoft and Pivotal, any security and other updates are delivered automatically behind the scenes, limiting service interruptions and reducing the risk of data compromise.
A road to multicloud Java
Using familiar tools for developers and for operations, Azure Spring Boot is an effective bridge between on-premises IT and the public cloud. If your code doesn’t take any dependencies on Azure services it’s a way of delivering hybrid and multicloud support. You can run the same code on premises and burst to Azure to handle spikes in demand. Or host the same applications on AWS and Azure and use a global DNS service to route users to the appropriate end point for minimum latency or to avoid service outages.
If you’re using Visual Studio Code for Java development, Pivotal provides a Spring Boot extension pack to add all the features that you need to deliver Spring Boot apps. These include IDE features for working with Spring Java code, as well as its configuration files. There are tools for deployment manifests, build pipelines, and a dashboard to help debug all your Spring Boot projects. A single installer sets up and configures all the tools, so you can get to work on your code without spending too much time tweaking your development environment.
It’s important to keep things simple when working with the public cloud. Complex applications are hard to debug, hard to scale, and harder still to understand what they’ll cost to run. By reducing dependencies on middleware and with direct integration with Azure services, Azure Spring Cloud should give you a predictable, understandable framework for deploying Java application on Azure without changing how you develop and test your code; code that should run anywhere you have Spring Boot installed.