Introduction to Azure Spring Apps— Part 1: Introduction, Azure Setup

Sudeep Moothedath
6 min readApr 12, 2020

--

Azure Spring Apps is a managed environment built by Microsoft and VMware with pre-configured, opinionated, ready-to-deploy infrastructure services and runtime for Spring-based applications.

For the Spring Boot developers who have worked with Pivotal Cloud Foundry or Tanzu Application Services, the availability of a managed environment that provides infrastructure services such as a Spring Cloud Service Discovery, Spring Cloud Config Server, auto configuration of properties, and more, has been a major advantage. It helps them to avoid the need to create, deploy and manage applications or services that can provide this functionality. The VMware and Microsoft partnership brings these features to Azure.

[Update 9/2/2020: Microsoft Announced the General Availability version during the SpringOne 2020]

[Update 12/1/2022: Microsoft Announced the renaming of Azure Spring Cloud to Azure Spring Apps during the Microsoft Build 2022. Updating this series to change the name and all the “az” command groups]

Azure Spring Apps

This article is the Part 1 of a series of 3 articles. Refer to Part 2 and Part 3 for continuation.

Sample Applications

Let’s dive straight into a set of sample applications that can demonstrate the features of Azure Spring Apps and instructions on configuring and using them.

For this example, we’ll create two microservices — an Order Service and Inventory Service.

The Order Service will receive an order, and it will invoke the Inventory Service to update the inventory. The Order Service will make use of the Service Registry (Eureka) feature of Azure Spring Apps to look up references to the inventory service.

The Inventory Service will receive a request to update the inventory. It will look for a feature flag value in a configuration file and, based on the value, the inventory data in the Cosmos DB will be updated. The Inventory Service will make use of Service Registry (Eureka), Config Server (Git) and Cosmos DB binding of Azure Spring Apps.

The final code for these applications are available in Github @ Service, Inventory Service, Config Server.

In addition to the specific features of Azure Spring Apps, we will cover some of the common errors and issues, along with their solutions.

Azure Setup

Before we proceed further, we need to set up the Azure. We will be using Azure CLI throughout this example since Azure Spring Apps applications cannot be deployed through Portal at the time of this writing. If you do not have the Azure CLI, it can be installed from here.

We will assume that you have an existing subscription with no other resources. First, login to Azure and create a resource group:

az group create -n <name> -l <location>

Create a Cosmos DB:

az cosmosdb create -n <name> -g <resource_group_name> --locations regionName=<location>

Cosmos DB creation may take some time.

Once Cosmos DB is created, navigate to the DB Blade and go to the Data Explorer section. You’ll see that there is no database. Extend the arrow near New Container and select New Database.

Add a New Database

Provide a Database Id and create

Create New Database

Once the database is created, you can expand the DB and make sure that there are no containers under that.

Newly created database

Next, create the Azure Spring Apps. spring command is available through an extension. First install the extension

az extension add -n spring

If there is an existing installation from the spring-cloud, it can be removed with the below command

az extension remove -n spring-cloud

Azure Spring Apps is not available in all locations. One of the available locations is `eastus`.

az spring create -n <spring_cloud_name> -g <resource_group_name> -l eastus

Creation of the Azure Spring Apps through the Portal provides some extra defaults that are not available while creating through CLI, such as the ability to create and associate Log Analytics workspace and Application Insight. In addition to this, a Diagnostics Settings to send the Application Logs to this workspace is also created by default. This is a nice addition in the current version.

The spring CLI extension provides an option to tail the application logs. The details are available here. While we were working with v0.1.0, lack of this feature necessitated the creation of a Log Analytics workspace. With the option to tail logs, there is no need to create a Log Analytics workspace, unless you want to query older logs or retain them for future use.

If you do need to manually create the Log Analytics workspace, then follow the below instructions. Otherwise, proceed to the Create Application section.

Refer here for Log Analytics workspace setup.

Create Application

Before we can deploy our Inventory application, we need to create the application manually in Azure. It can be done in the Portal under the Apps section in the left pane or using the CLI.

az spring app create -n <name_of_app> -s <name_of_azure_spring_app> -g <resource_group_name> --assign-endpoint true

The endpoint can be copied from the Portal.

Inventory Service — Select the URL

Accessing it will provide a welcome page as below

Inventory Service Welcome Page

For this example, I named the application as inventory-service. Now, we need to connect the database to our inventory-service app. This is done through Service Binding. Navigate to the Spring Cloud App resource and access the Apps from the Left Navigation and click on the inventory-service app.

Azure Spring Apps

Access the Service bindings option from the Left Navigation and click Create service binding

Service Bindings

Provide the requested fields and create a binding. For the Key, the Primary Master Key can be selected.

Once the binding is created, restart the app. Even though the Portal will show immediately that the app is restarted, wait for the App Instance to reflect that. Azure uses blue-green deployments. This is achieved by creating a new instance of the app with the Service binding. Until the new instance is up and running, the traffic will continue to flow to the old instance. This can be verified by accessing the App Instances tab on the Left Navigation. You’ll see two instances.

App Instances

The existing instance is shown as “Retiring” and the new instance is in “Pending”. Wait for only one instance to be available in “Running” status.

At this point, we are ready to start the deployment of our code. This is handled in the subsequent posts in this series.

Introduction to Azure Spring Apps — Part 2: Inventory Service

Introduction to Azure Spring Apps — Part 3: Order Service

--

--