Table of contents
1.
Introduction
2.
Spring Cloud Application to Azure Spring Apps
3.
Pre-Migration
3.1.
Examine the Application's Components
3.1.1.
Check the file system
3.1.2.
Handle OS-specific codes
3.1.3.
Migrate to the supported Java version in the current environment
3.1.4.
Obtain the Spring Boot Version
3.1.5.
Obtain the Spring Cloud version 
3.1.6.
Review log aggregation solution
3.1.7.
Identify APM agents
3.1.8.
Identify Zipkin dependencies
3.2.
List External resources 
3.2.1.
Databases
3.2.2.
JMS message brokers
3.2.3.
External Caches
3.2.4.
Identity and Authorization 
3.2.5.
Resources configured through VMware TAS
3.3.
All other remaining External Resources
3.4.
List the configuration sources
3.4.1.
List passwords or secret strings
3.4.2.
List Certificates 
3.4.3.
Check for Spring Cloud Vault
3.4.4.
Find the configuration server source
3.5.
Look over the deployment architecture
3.5.1.
For each Service, document the hardware requirements
3.5.2.
Document distribution/geo-replication
3.5.3.
Determine which clients evade the service registry
4.
Migration 
4.1.
Eliminate explicit configuration server settings
4.2.
Create an Azure Spring Apps Instance
4.3.
Prepare the Spring Cloud Config server
4.4.
Make sure console logging is enabled and set up diagnostics
4.5.
Configure Persistent Storage
4.6.
Migrate all certificates to KeyVault
4.7.
Migrate Spring Cloud Vault secrets to Azure KeyVault
4.8.
Eliminate explicit Zipkin dependencies
4.9.
Remove APM integrations
4.10.
Disable Metrics Clients and Endpoints
4.11.
Deploy on Azure Spring Apps
4.12.
Setup Externalised Settings and per-service secrets
4.13.
Migrate and enable the identity provider
4.14.
Update client applications
5.
Post-migration
6.
Frequently Asked Questions
6.1.
What is Microsoft Azure?
6.2.
What is Azure Kubernetes Services?
6.3.
What are Azure Spring Apps?
6.4.
How do you handle OS-specific codes when migrating from Spring cloud application to Azure Spring Apps?
6.5.
How can you find the external resources in the spring cloud application?
7.
Conclusion
Last Updated: Mar 27, 2024

Spring Cloud Application to Azure Spring Apps

Author Teesha Goyal
0 upvote
Career growth poll
Do you think IIT Guwahati certified course can help you in your career?

Introduction

Azure Spring apps were formerly known as Azure Spring Cloud services. It is an open-source platform to integrate spring with Azure services. It is easy to use, requiring menial code changes and a few configuration lines. 

This article will discuss migrating a Spring Cloud Application to Azure Spring Apps.

Azure Spring Apps logo

Spring Cloud Application to Azure Spring Apps

Moving an existing Spring cloud application to the Azure spring app requires specific steps divided into three stages. They are:

  • Pre-migration
  • Migration
  • Post-migration

Stages of Migrating

Some steps under the pre-migration, migration, and post-migration phases are necessary to move a spring cloud application to run on Azure Spring Apps. Now, we will discuss each of these phases in detail.

Pre-Migration

Before migrating Spring cloud applications to Azure Spring apps, some essential things must be checked and taken care of. Such steps come under the pre-migration phase. 

Examine the Application's Components

The most important thing to do at the beginning of migrating an existing spring cloud application to Azure Spring Apps is to inspect/examine the application's components. 

Examine the Application's Components

Check the file system

When we migrate the spring cloud application to Azure Spring Apps, it becomes vital to reconfigure the file system being used. In rare cases, we may also require changing the file system's architecture. That is why it becomes necessary to determine whether and how the file system is used. We need to know where the short-term lived files are stored and where the long-term lived files are stored. 

A spring cloud application can be static or dynamic, and the approach to handle both situations is different. Following are the two situations regarding file system management:

  • Static Content: If your application is static and has only static content, then it is easier to handle the file system; you just have to change the location of the data. You can move the content to Azure Blob Storage and add Azure CDN. By adding Azure CDN, you can ensure that your site provides high-speed downloading globally. 
     
  • Static Content published dynamically: If your applications allow dynamically publishing or statically uploading data, it cannot be modified after creation.  Azure Blob storage and Azure CDN can be used. An Azure function handles uploads and CDN refresh. 

 

Handle OS-specific codes

If your application contains OS-specific codes that have dependencies on the host OS, it becomes crucial to remove these dependencies. One such way is by removing the / or \ symbols with paths.get or File.Separator in the file system. 

Migrate to the supported Java version in the current environment

It is crucial to validate that our application works correctly on the supported java version. Various Java versions are available; it is good to find the best-suited java version in the current environment and then migrate to Azure Spring apps. It becomes more critical when we are dealing with unsupported JDK. 

Java Development Kit

To check the java version used in your application, you can run the following command in your production server.

java -version

 

Obtain the Spring Boot Version

It is also essential to determine the spring boot version before migrating a Spring Boot Application to Azure Spring Apps. To do so, we have to find the migrated application's spring boot version—the method to find the spring boot version is different in Maven and Gradle Projects.

 

Maven Projects

The spring boot version is in the <parent> element of the project object model file.

Following is an example of <parent> element of the POM file:

<parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.3.4.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository →
</parent>

 

Gradle Projects

The spring boot version in Gradle projects is found in the plugins section. Inside the plugins sections, you will find two different versions; the spring boot version is the one found by the id name of org.springframework.boot.

Following is an example of plugins section in the POM file:

plugins {
  id 'org.springframework.boot' version '1.3.7.RELEASE'
  id 'io.spring.dependency-management' version '1.1.6.RELEASE'
  id 'java'
}

 

Obtain the Spring Cloud version 

You must identify the Spring Cloud version for the application you aim to migrate to Azure Spring Apps. The version of each component of an application that is being migrated must be known. The method to find the spring cloud version is different in Maven and Gradle Projects.

Spring Cloud

Maven Projects

The spring cloud version is in the spring-cloud.version property of the project.

Following is an example of spring-cloud.version property of the project

<properties>
    <java.version>1.</java.version>
    <spring-cloud.version>Hoxton.SR12</spring-cloud.version>
  </properties>

 

Gradle Projects

The spring cloud version in Gradle projects is found in the "extra properties" block of the project.

Following is an example

ext {
  set('springCloudVersion', "Hoxton.SR12")
}

 

Review log aggregation solution

Check whether and what log aggregation solutions are in the application you want to migrate. 

Identify APM agents

Determine the APM (application performance management) agents associated with your project/application. Azure Spring Apps provides strong integration with Azure Monitor and real-time response to aberrations.  

Identify Zipkin dependencies

If your application has specific dependencies on Zipkin, it must be identified in advance. To do so, you can check the io.zipkin.java group in your Maven or Gradle dependencies.

List External resources 

Identify all the external resources associated with your application. Such resources can be JMS message brokers, data sources, and URLs of other services. You can go to the src/main/directory folder to find the external resources in the spring cloud application. Inside this folder, you can look for application.properties or application.yml file containing the external resources associated with your application. 

Databases

You must identify the connection string for any SQL database integrated with your application. It is typically found in the configuration files. There are two files in the src/main/directory folder: application.properties and application.yml file. 

Databases

JMS message brokers

Another external resource to be identified is JSM message brokers. You can look in the build manifest to find the brokers in your application. Two files contain this information; they are pom.xml or build.gradle file.

Following is an example of finding a broker in pom.xml file:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-activemq</artifactId>
</dependency>

 

Following is an example of finding commercial brokers in build.gradle file:

dependencies {
      ...
      compile("com.ibm.mq:com.ibm.mq.allclient:9.0.4.0")
      ...
    }

 

The next step is to find the corresponding settings. It can be found in the application.properties and application.yml files.  

Following is an example of IBM MQ from application.yaml file:

ibm:
  mq:
    queueManager: qm1
    channel: dev.ORDERS
    connName: localhost(14)
    user: admin
    password: big$ecr3t

 

External Caches

Yet another external resource is the external cache. You need to identify the external cache in use by your application beforehand. Redis is used through Spring Data Redis. Search for the relevant configuration to determine whether Session data is cached through Spring Session.

Identity and Authorization 

Identify whether your spring cloud application requires authentication and authorization. Also, identify all the identity providers. Following are the resources you can use to understand how to configure different identity providers:

 

Resources configured through VMware TAS

For the applications that are managed via TAS (Tanzu application Service), all the external resources are configured through TAS service bindings.

VMware TAS

The VCAP_SERVICES variable holds all the information regarding the configuration of these external resources. To view the VCAP_SERVICES variable, you can use the Cloud Foundry Command Line Interface (cf CLI)

Example of how you can view the configuration of external resources:

# Log into Tanzu application service, if needed (enter credentials when prompted)
cf login -a <API endpoint>

# Set the organization and space name containing the application, if not already selected during login.
cf target org <Organization_Name>
cf target space <Space_Name>

# Display variables for the application
cf env <Application_Name>

 

All other remaining External Resources

There are a lot of external dependencies, and it is not possible to mention every single one of them. Your responsibility is to look out for your application and handle each external dependency explicitly and carefully. 

List the configuration sources

List passwords or secret strings

Check the application.properties or application.yml file for any secret strings or passwords inside your application. You must check the configurations, properties, and environment variables for any passwords or secret strings.

List Certificates 

Record every certificate for communication with backend databases and other systems or with public SSL endpoints. To view the list of all certificates on the production server(s), you can run the following command:

keytool -list -v -keystore <path to keystore>

 

Check for Spring Cloud Vault

Suppose your application uses a spring cloud vault to store and access secrets and identify secret backing stores, listing down all the secrets used by the application code. This information comes in handy when migrating the spring cloud application to Azure Spring Apps.

Find the configuration server source

The next important step to pay attention to is to locate the configuration server source. If your Spring cloud application uses Spring Cloud Config Server, you must identify where all the configurations are stored. 

It is typically found in the configuration files. There are two files in the src/main/directory folder: application.properties and application.yml file. 

It can also be found in the bootstrap.yml or bootstrap.properties file. 

An example of the setting is shown below:

spring.cloud.config.server.git.uri: file://${user.home}/spring-cloud-config-repo

 

Look over the deployment architecture

For each Service, document the hardware requirements

Document the following hardware requirements for your application before moving it to Azure Spring Apps:

  • Count of running instances.
  • Count of CPUs allocated to each instance.
  • Amount of RAM assigned to each instance.

 

Document distribution/geo-replication

Find out if your Spring cloud application instances are currently dispersed across several locations or data centers. Record the SLA and uptime requirements for the migrating application.

Determine which clients evade the service registry

The client applications that use any services that will be migrated but not through the Spring Cloud Service Registry should be identified. Such invocations won't be feasible following the migration. Before shifting, update such clients to use Spring Cloud OpenFeign.

Migration 

Now that you have done the pre-migration procedures and understand all the essential factors, it’s time to move ahead with the migration process of the spring cloud application to Azure Spring Apps. All the information collected earlier will be handy when moving the application.

Eliminate explicit configuration server settings

If your spring cloud application has any explicit assignments of Eureka settings, then you must eliminate them. It is typically found in the configuration files. 

Eliminate explicit configuration server settings

There are two files in the src/main/directory folder: application.properties and application.yml file. 

Example of application.yml 

eureka:
  client:
    serviceUrl:
      defaultZone: http://myusername:mysecretpassword@localhost:8761/eureka/

 

Remove this setting if it occurs in the application configuration. Azure Spring Apps will automatically inject the configuration server's connection information.

Create an Azure Spring Apps Instance

The first thing you need to do in Azure Spring Apps is to create an instance under your Azure subscription if you don't already have one. Next, you need to create applications inside your Azure Spring Apps instance. 

Prepare the Spring Cloud Config server

The next step is configuring the Spring cloud server in your Azure Spring Apps. If your current Spring Cloud Config repository is a local file system, you must move it to any cloud platform to integrate it with your Azure Spring Apps instances. 

Make sure console logging is enabled and set up diagnostics

You must configure the console logging to log in to the console and not the files directly. Add diagnostics settings once an application is deployed on Azure Spring Apps to monitor the log events. 

You can use one of the two log aggregation:

  • LogStash/ELK Stack
  • Splunk

Configure Persistent Storage

If your application requires persistent non-volatile storage, you must configure the Azure Persistent Volumes. The persistent volume can be provisioned statically and dynamically as per the needs. In case of any read and write operations to the local state, you must move the data to persistent volumes; otherwise, you can lose it.

To ensure that the temporary data is not lost, you should move the temporary files to the /tmp directory.

Migrate all certificates to KeyVault

You must migrate all the certificates listed in the pre-migration stage to KeyVault because Azure Spring Apps does not provide access to the JRE Keystore. You will also need to change the application code to be able to access certificates in KeyVault.

certificates to KeyVault

Migrate Spring Cloud Vault secrets to Azure KeyVault

You must move all the Spring Cloud Vault identified in the pre-migration stage to Azure KeyVault. You can use the Azure KeyVault Spring Boot Starters to inject the secrets directly into the application.  

You might have to rename some secrets during migration. Adapt the application code as necessary.

Eliminate explicit Zipkin dependencies

Now, Spring Cloud Starters must replace any Zipkin dependencies identified in the pre-migration phase.

Remove APM integrations

You must eliminate any integrations with APM (application performance management) agents associated with your application. 

Disable Metrics Clients and Endpoints

If your application has metric clients or endpoints, you need to disable them.

Deploy on Azure Spring Apps

Deploy your application to the Azure Spring Apps. You must deploy each migrated microservices except for the Spring Cloud Config and Registry servers.

Setup Externalised Settings and per-service secrets

To set up externalized settings and per-service secrets, you must have Azure Portal. Following the below steps on the Azure portal to do so:

  • Go to the Azure Spring Apps Instance and click on Apps.
  • Select the service you want to configure.
  • Click Configuration.
  • Enter the variable you want to configure
  • Click Save.

Migrate and enable the identity provider

Use the inventory created in the pre-migration stage and ensure that all the authorization and authentication services are configured per the requirements. 

Update client applications

All client applications should update their configurations to use the migrated applications' published Azure Spring Apps endpoints.

Post-migration

You are done with the migration part. You have completed your spring cloud application migration to Azure Spring Apps. You must ensure that the application works as expected by monitoring and maintaining the application. We have provided some suggestions you can apply to your application to ensure smooth working.  

  • For automatic, dependable deployments, take into account building a deployment pipeline.
  • Consider adding an Azure Application Gateway to offer SSL offloading and a Web Application Firewall with DDoS protection if geo-replication is not required.
  • When connecting your application to supported Azure databases, consider adding service bindings. You wouldn't have to give your Spring Cloud applications any connection details, such as credentials, due to these service bindings.
  • To quickly identify and respond to unexpected conditions, consider implementing Azure Monitor alert rules and action groups.

Frequently Asked Questions

What is Microsoft Azure?

Microsoft Azure is a leading cloud platform that lets you access the cloud services and resources provided by Microsoft. It provides various services, including computation, storage, analytics, and networking. 

What is Azure Kubernetes Services?

Azure Kubernetes Service(AKS) is a fully managed container management service. It ensures container orchestration. It is provided by Microsoft Azure which is the leading cloud service provider. 

What are Azure Spring Apps?

Azure Spring apps were formerly known as Azure Spring Cloud services. It is an open-source platform to integrate spring with Azure services. It is easy to use, requiring menial code changes and a few configuration lines. 

How do you handle OS-specific codes when migrating from Spring cloud application to Azure Spring Apps?

If your application contains OS-specific codes that have dependencies on the host OS, it becomes crucial to remove these dependencies. One such way is by removing the / or \ symbols with paths.get or File.Separator in the file system.  

How can you find the external resources in the spring cloud application?

You can go to the src/main/directory folder to find the external resources in the spring cloud application. Inside this folder, you can look for application.properties or application.yml file containing the external resources associated with your application. 

Conclusion

This article discussed migrating a spring cloud application to Azure Spring Apps. We discussed in detail the pre-migration, migration, and post-migrations steps to migrate your spring cloud application to Azure Spring Apps. 

I hope you would have gained a better understanding of these topics now!

Are you planning to ace the interviews of reputed product-based companies like AmazonGoogleMicrosoft, and more? 

Attempt our Online Mock Test Series on Coding Ninjas Studio now!

Thank You

Happy Coding!

Live masterclass