Quickstart: Deploy your first application to Azure Spring Apps

Select an Azure Spring Apps plan

Note

The Basic, Standard, and Enterprise plans will be deprecated starting from mid-March, 2025, with a 3 year retirement period. We recommend transitioning to Azure Container Apps. For more information, see the Azure Spring Apps retirement announcement.

The Standard consumption and dedicated plan will be deprecated starting September 30, 2024, with a complete shutdown after six months. We recommend transitioning to Azure Container Apps. For more information, see Migrate Azure Spring Apps Standard consumption and dedicated plan to Azure Container Apps.

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 complete this example, the application is accessible online, and you can manage it through the Azure portal.

This article provides the following options for deploying to Azure Spring Apps:

  • The Azure portal option is the easiest and the fastest way to create resources and deploy applications with a single click. This option is suitable for Spring developers who want to quickly deploy applications to Azure cloud services.
  • The Azure portal + Maven plugin option is a more conventional way to create resources and deploy applications step by step. This option is suitable for Spring developers using Azure cloud services for the first time.
  • The Azure Developer CLI option is a more efficient way to automatically create resources and deploy applications through simple commands. The Azure Developer CLI uses a template to provision the Azure resources needed and to deploy the application code. This option is suitable for Spring developers who are familiar with Azure cloud services.
  • The Azure portal option is the easiest and the fastest way to create resources and deploy applications with a single click. This option is suitable for Spring developers who want to quickly deploy applications to Azure cloud services.
  • The Azure portal + Maven plugin option is a more conventional way to create resources and deploy applications step by step. This option is suitable for Spring developers using Azure cloud services for the first time.
  • The Azure CLI option uses a powerful command line tool to manage Azure resources. This option is suitable for Spring developers who are familiar with Azure cloud services.
  • The IntelliJ option uses a powerful Java IDE to easily manage Azure resources. This option is suitable for Spring developers who are familiar with Azure cloud services and IntelliJ IDEA.
  • The Visual Studio Code option uses a lightweight but powerful source code editor, which can easily manage Azure resources. This option is suitable for Spring developers who are familiar with Azure cloud services and Visual Studio Code.

1. Prerequisites

2. Prepare the Spring project

The Deploy to Azure button in the next section launches an Azure portal experience that downloads a JAR package from the spring-cloud-azure-tools releases page on GitHub. No local preparation steps are needed.

3. Prepare the cloud environment

This section describes how to create an Azure Spring Apps service instance and prepare the Azure cloud environment.

This section uses a Deploy to Azure button to launch a deployment experience in the Azure portal. This experience uses an ARM template to create Azure resources.

3.1. Sign in to the Azure portal

Go to the Azure portal and enter your credentials to sign in to the portal. The default view is your service dashboard.

3.2. Create Azure resources

Use the following steps to create all the Azure resources that the app depends on:

  1. Select the following Deploy to Azure button to launch the deployment experience in the Azure portal:

    Button to deploy the Resource Manager template to Azure.

  2. Fill out the form on the Basics tab. Use the following table as a guide for completing the form:

    Setting Suggested value Description
    Subscription Your subscription name. The Azure subscription that you want to use for your server. If you have multiple subscriptions, choose the subscription in which you'd like to be billed for the resource.
    Resource group myresourcegroup A new resource group name or an existing one from your subscription.
    Region The region closest to your users. The region is used to create the resource group.
  3. Select Review and Create to review your selections. Then, select Create to deploy the app to Azure Spring Apps.

  4. On the toolbar, select the Notifications icon (a bell) to monitor the deployment process. After the deployment finishes, you can select Pin to dashboard, which creates a tile for this service on your Azure portal dashboard as a shortcut to the service's Overview page. Select Go to resource to open the service's Overview page.

    Screenshot of the Azure portal that shows the Overview page with the custom deployment notifications pane open.

4. Deploy the app to Azure Spring Apps

The Deploy to Azure button in the previous section launches an Azure portal experience that includes application deployment, so nothing else is needed.

2. Prepare the Spring project

The Deploy to Azure button in the next section launches an Azure portal experience that downloads a JAR package from the spring-cloud-azure-tools releases page on GitHub. No local preparation steps are needed.

3. Prepare the cloud environment

This section describes how to create an Azure Spring Apps service instance and prepare the Azure cloud environment.

This section uses a Deploy to Azure button to launch a deployment experience in the Azure portal. This experience uses an ARM template to create Azure resources.

3.1. Sign in to the Azure portal

Go to the Azure portal and enter your credentials to sign in to the portal. The default view is your service dashboard.

3.2. Create Azure resources

Use the following steps to create all the Azure resources that the app depends on:

  1. Select the following Deploy to Azure button to launch the deployment experience in the Azure portal:

    Button to deploy the Resource Manager template to Azure.

  2. Fill out the form on the Basics tab. Use the following table as a guide for completing the form:

    Setting Suggested value Description
    Subscription Your subscription name. The Azure subscription that you want to use for your server. If you have multiple subscriptions, choose the subscription in which you'd like to be billed for the resource.
    Resource group myresourcegroup A new resource group name or an existing one from your subscription.
    Region The region closest to your users. The region is used to create the resource group.
  3. Select Review and Create to review your selections. Then, select Create to deploy the app to Azure Spring Apps.

  4. On the toolbar, select the Notifications icon (a bell) to monitor the deployment process. After the deployment finishes, you can select Pin to dashboard, which creates a tile for this service on your Azure portal dashboard as a shortcut to the service's Overview page. Select Go to resource to open the service's Overview page.

    Screenshot of the Azure portal that shows the Overview page with the custom deployment notifications pane open.

4. Deploy the app to Azure Spring Apps

The Deploy to Azure button in the previous section launches an Azure portal experience that includes application deployment, so nothing else is needed.

2. Prepare the Spring project

Use the following steps to create the project:

  1. Use the following command to generate a sample project from start.spring.io with the recommended dependencies for Azure Spring Apps:

    curl https://start.spring.io/starter.tgz -d dependencies=web -d baseDir=demo -d bootVersion=3.0.0 -d javaVersion=17 -d type=maven-project -d groupId=com.example -d artifactId=demo -d name=demo -d packageName=com.example.demo -d packaging=jar | tar -xzvf -
    
  2. Create a web controller for your web application by adding the file src/main/java/com/example/demo/HelloController.java with the following contents:

    package com.example.demo;
    
    import org.springframework.web.bind.annotation.RestController;
    import org.springframework.web.bind.annotation.RequestMapping;
    
    @RestController
    public class HelloController {
    
        @RequestMapping("/")
        public String index() {
            return "Hello World";
         }
    }
    
  3. Use the following Maven command to build the project:

    ./mvnw clean package
    
  4. Run the sample project locally by using the following command:

    ./mvnw spring-boot:run
    

3. Prepare the cloud environment

This section describes how to create an Azure Spring Apps service instance and prepare the Azure cloud environment.

3.1. Sign in to the Azure portal

Open your web browser and go to the Azure portal, enter your credentials, and sign in to the portal. The default view is your service dashboard.

3.2. Create an Azure Spring Apps instance

Use the following steps to create the service instance:

  1. Select Create a resource in the corner of the Azure portal.

  2. Select Compute > Azure Spring Apps.

  3. Fill out the Basics form with the following information:

    Setting Suggested value Description
    Subscription Your subscription name. The Azure subscription that you want to use for your server. If you have multiple subscriptions, choose the subscription in which you'd like to be billed for the resource.
    Resource group myresourcegroup A new resource group name or an existing one from your subscription.
    Name myasa A unique name that identifies your Azure Spring Apps service. The name must be between 4 and 32 characters long and can contain only lowercase letters, numbers, and hyphens. The first character of the service name must be a letter and the last character must be either a letter or a number.
    Region The region closest to your users. The location that is closest to your users.
    Hosting options and plans Enterprise The pricing plan that determines the resource and cost associated with your instance.
    Zone Redundant Unselected The option to create your Azure Spring Apps service in an Azure availability zone. This feature isn't currently supported in all regions.
    Software IP Plan Pay-as-You-Go The pricing plan that lets you pay as you go with Azure Spring Apps.
    Deploy sample project Unselected The option to use the built-in sample application.
  4. Select Review and Create to review your selections. Then, select Create to provision the Azure Spring Apps instance.

  5. On the toolbar, select the Notifications icon (a bell) to monitor the deployment process. After the deployment finishes, you can select Pin to dashboard, which creates a tile for this service on your Azure portal dashboard as a shortcut to the service's Overview page.

    Screenshot of the Azure portal that shows the Notifications pane for Azure Spring Apps creation.

  6. Select Go to resource to go to the Azure Spring Apps Overview page.

4. Deploy the app to Azure Spring Apps

This section provides the steps to deploy your application to Azure Spring Apps.

4.1. Import the project

Use the following steps to import the project:

  1. Open IntelliJ IDEA and select Open.

  2. In the Open File or Project dialog box, select the demo folder.

    Screenshot of IntelliJ IDEA that shows the Open File or Project dialog box.

4.2. Build and deploy your app

Use the following steps to build and deploy your app:

  1. If you didn't already install the Azure Toolkit for IntelliJ, follow the steps in Install the Azure Toolkit for IntelliJ.

    Note

    Azure Toolkit for IntelliJ provides four ways to log in to Azure, and the deployment can only start after logging in.

  2. Right-click your project in the IntelliJ Project window and then select Azure -> Deploy to Azure Spring Apps.

    Screenshot of the IntelliJ IDEA menu that shows the Deploy to Azure Spring Apps option.

  3. Accept the name for the app in the Name field. Name refers to the configuration, not the app name. You don't usually need to change it.

  4. In the Artifact textbox, select Maven:demo(Java 17).

  5. In the Subscription textbox, verify that your subscription is correct.

  6. In the Spring Apps textbox, select the instance of Azure Spring Apps that you created.

  7. In the App textbox, select the plus sign (+) to create a new app.

    Screenshot of the IntelliJ IDEA that shows the Deploy Azure Spring Apps dialog box.

  8. In the App name: textbox under App Basics, enter demo, and then select More settings.

  9. Select the Enable button next to Public endpoint. The button changes to Disable <to be enabled>. Then, select OK.

    Screenshot of IntelliJ IDEA Create app dialog box with public endpoint Disable button highlighted.

  10. Under Before launch, select Run Maven Goal 'demo:package', and then select the pencil icon to edit the command line.

    Screenshot of IntelliJ IDEA Create Azure Spring Apps dialog box with Maven Goal edit button highlighted.

  11. In the Command line textbox, enter -DskipTests after package, and then select OK.

    Screenshot of IntelliJ IDEA Select Maven Goal dialog box with Command Line value highlighted.

  12. To start the deployment, select the Run button at the bottom of the Deploy to Azure dialog box. The plug-in runs the Maven command package -DskipTests on the demo app and deploys the .jar file generated by the package command.

Deploying the application can take a few minutes. You can see the public URL of the application in the output console log.

5. Validate the app

This section describes how to validate your application.

After the deployment finishes, find the application URL from the deployment outputs. Use the following steps to validate:

  1. Access the application URL from the Outputs page of the Deployment. When you open the app, you get the response Hello World.

    Screenshot of the Azure portal that shows the Outputs page of the Deployment.

  2. Check the details for each resource deployment, which are useful for investigating any deployment issues.

After the deployment finishes, use the following steps to find the application URL from the deployment outputs:

  1. Access the application URL from the Outputs page of the Deployment. When you open the app, you get the response Hello World.

    Screenshot of the Azure portal that shows the Outputs page of the Deployment.

  2. Check the details for each resource deployment, which are useful for investigating any deployment issues.

Use the following steps to stream your application logs:

  1. Access the application with the output application URL. When you open the app, you get the response Hello World.

  2. Open the Azure Explorer window, expand the node Azure, expand the service node Azure Spring Apps, expand the Azure Spring Apps instance you created, and then select the demo instance of the app you created.

  3. Right-click and select Start Streaming Logs, then select OK to see real-time application logs.

    Screenshot of IntelliJ that shows the Azure Streaming Log.

6. 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, you can clean up unnecessary resources to avoid Azure charges.

Use the following steps to delete the resource group by using IntelliJ:

  1. Go to your IntelliJ IDEA and find the name of your resource group.

  2. Right-click the resource group and select Delete to delete all related Azure resources.

Use the following steps to delete the entire resource group, including the newly created service instance:

  1. Locate your resource group in the Azure portal. On the navigation menu, select Resource groups, and then select the name of your resource group.

7. Next steps

For more information, see the following articles: