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: ✔️ Basic/Standard tier ✔️ Enterprise tier

This quickstart 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 will be 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'll have a working spring app running on Azure Spring Apps.

Prerequisites

Provision an instance of Azure Spring Apps

Use the following steps to provision a service instance.

  1. Select Try It and sign in to your Azure account in Azure Cloud Shell.

    az account show
    
  2. Azure Cloud Shell workspaces are temporary. On initial start, the shell prompts you to associate 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 choose and link to your 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 <service-instance-name>
    
  7. Choose Y to install the Azure Spring Apps extension and run it.

Create an app in your Azure Spring Apps 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 <service-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 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 <service-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 generate a basic Spring project, provision a service instance, build and deploy an app with a public endpoint, and clean up the resources.

You also 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:

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