Quickstart: Deploy your first application to Azure Spring Apps

Note

The first 50 vCPU hours and 100 GB hours of memory are free each month. For more information, see Price Reduction - Azure Spring Apps does more, costs less! on the Apps on Azure Blog.

Note

Azure Spring Apps is the new name for the Azure Spring Cloud service. Although the service has a new name, you'll see the old name in some places for a while as we work to update assets such as screenshots, videos, and diagrams.

This article applies to: ✔️ Standard consumption (Preview) ✔️ Basic/Standard ✔️ Enterprise

This article explains how to deploy a small application to run on Azure Spring Apps.

The application code used in this tutorial is a simple app. When you've completed this example, the application is accessible online, and you can manage it through the Azure portal.

This quickstart explains how to:

  • Generate a basic Spring project.
  • Provision a service instance.
  • Build and deploy an app with a public endpoint.
  • Clean up the resources.

At the end of this quickstart, you have a working Spring app running on Azure Spring Apps.

Prerequisites

Provision an instance of Azure Spring Apps

Use the following steps to create an Azure Spring Apps service instance.

  1. Select Open Cloudshell and sign in to your Azure account in Azure Cloud Shell.

    az account show
    
  2. Azure Cloud Shell workspaces are temporary. When first started, the shell prompts you to select an Azure Storage instance with your subscription to persist files across sessions.

    Screenshot of Azure Storage subscription.

  3. After you sign in successfully, use the following command to display a list of your subscriptions.

    az account list --output table
    
  4. Use the following command to set your default subscription.

    az account set --subscription <subscription-ID>
    
  5. Use the following command to create a resource group.

    az group create \
        --resource-group <name-of-resource-group> \
        --location eastus
    
  6. Use the following command to create an Azure Spring Apps service instance.

    az spring create \
        --resource-group <name-of-resource-group> \
        --name <Azure-Spring-Apps-instance-name>
    
  7. Select Y to install the Azure Spring Apps extension and run it.

Create an app in your Azure Spring Apps instance

An App is an abstraction of one business app. Apps run in an Azure Spring Apps service instance, as shown in the following diagram.

Diagram showing the relationship between apps and an Azure Spring Apps service instance.

Use the following command to specify the app name on Azure Spring Apps as hellospring.

az spring app create \
    --resource-group <name-of-resource-group> \
    --service <Azure-Spring-Apps-instance-name> \
    --name hellospring \
    --assign-endpoint true

Clone and build the Spring Boot sample project

Use the following steps to clone the Spring Boot sample project.

  1. Use the following command to clone the Spring Boot sample project from GitHub.

    git clone -b boot-2.7 https://github.com/spring-guides/gs-spring-boot.git
    
  2. Use the following command to move to the project folder.

    cd gs-spring-boot/complete
    
  3. Use the following Maven command to build the project.

    mvn clean package -DskipTests
    

Deploy the local app to Azure Spring Apps

Use the following command to deploy the .jar file for the app (target/spring-boot-complete-0.0.1-SNAPSHOT.jar on Windows).

az spring app deploy \
    --resource-group <name-of-resource-group> \
    --service <Azure-Spring-Apps-instance-name> \
    --name hellospring \
    --artifact-path target/spring-boot-complete-0.0.1-SNAPSHOT.jar

Deploying the application can take a few minutes.

Once deployment has completed, you can access the app at https://<service-instance-name>-hellospring.azuremicroservices.io/.

Clean up resources

If you plan to continue working with subsequent quickstarts and tutorials, you might want to leave these resources in place. When you no longer need the resources, delete them by deleting the resource group. Use the following commands to delete the resource group:

echo "Enter the Resource Group name:" &&
read resourceGroupName &&
az group delete --name $resourceGroupName &&
echo "Press [ENTER] to continue ..."

Next steps

In this quickstart, you learned how to build and deploy a Spring app in an Azure Spring Apps service instance. You also learned how to deploy an app with a public endpoint, and how to clean up resources.

You have access to powerful logs, metrics, and distributed tracing capability from the Azure portal. For more information, see Quickstart: Monitoring Azure Spring Apps apps with logs, metrics, and tracing.

To learn how to use more Azure Spring capabilities, advance to the quickstart series that deploys a sample application to Azure Spring Apps:

To learn how to create a Standard consumption plan in Azure Spring Apps for app deployment, advance to the Standard consumption quickstart series:

For a packaged app template with Azure Spring Apps infrastructure provisioned using Bicep, see Spring Boot PetClinic Microservices Application Deployed to Azure Spring Apps.

More samples are available on GitHub: Azure Spring Apps Samples.