Breyta

Deila með


Quickstart: Deploy your first web application to Azure Spring Apps

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 quickstart shows how to deploy a Spring Boot web application to Azure Spring Apps. The sample project is a simple ToDo application to add tasks, mark when they're complete, and then delete them. The following screenshot shows the application:

Screenshot of a sample web application in Azure Spring Apps.

This application is a typical three-layers web application with the following layers:

  • A frontend bounded React application.
  • A backend Spring web application that uses Spring Data JPA to access a relational database.
  • A relational database. For localhost, the application uses H2 Database Engine. For Azure Spring Apps, the application uses Azure Database for PostgreSQL. For more information about Azure Database for PostgreSQL, see Flexible Server documentation.

The following diagram shows the architecture of the system:

Diagram that shows the architecture of a Spring web application.

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 provides 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.

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 provides 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.

1. Prerequisites

  • An Azure subscription. If you don't have a subscription, create a free account before you begin.
  • An Azure subscription. If you don't have a subscription, create a free account before you begin.

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 ASA-Samples-Web-Application releases page on GitHub. No local preparation steps are needed.

3. Prepare the cloud environment

The main resources required to run this sample are an Azure Spring Apps instance and an Azure Database for PostgreSQL instance. This section provides the steps to create these resources.

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.
    Postgre SQL Admin Password N/A The password for the PostgreSQL Server administrator.
    Postgre SQL User Password N/A The password for the PostgreSQL application user, which is used in the application.

    Screenshot of the Azure portal that shows the custom deployment.

  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 ASA-Samples-Web-Application releases page on GitHub. No local preparation steps are needed.

3. Prepare the cloud environment

The main resources required to run this sample are an Azure Spring Apps instance and an Azure Database for PostgreSQL instance. This section provides the steps to create these resources.

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.
    PostgreSQL Admin Password N/A The password for the PostgreSQL Server administrator.
    PostgreSQL User Password N/A The password for the PostgreSQL application user, which is used in the application.

    Screenshot of the Azure portal that shows the custom deployment.

  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 ASA-Samples-Web-Application releases page on GitHub. No local preparation steps are needed.

3. Prepare the cloud environment

The main resources required to run this sample are an Azure Spring Apps instance and an Azure Database for PostgreSQL instance. This section provides the steps to create these resources.

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.
    Postgre SQL Admin Password N/A The password for the PostgreSQL Server administrator.
    Postgre SQL User Password N/A The password for the PostgreSQL application user, which is used in the application.

    Screenshot of the Azure portal that shows the custom deployment.

  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.

5. Validate the web app

Now you can access the deployed app to see whether it works.

Use the following steps to validate:

  1. After the deployment finishes, you can find the application URL from the deployment outputs:

    Diagram that shows the enterprise app URL of the ARM deployment outputs.

  2. Access the application with the output application URL. The page should appear as you saw in localhost.

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

Use the following steps to validate:

  1. After the deployment finishes, you can find the application URL from the deployment outputs:

    Diagram that shows the consumption app URL of the ARM deployment outputs.

  2. Access the application URL. The page should appear as you saw in localhost.

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

Use the following steps to validate:

  1. After the deployment finishes, find the application URL from the deployment outputs:

    Diagram that shows the standard app URL of the ARM deployment outputs.

  2. Access the application URL. The page should appear as you saw in localhost.

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

6. Clean up resources

Be sure to delete the resources you created in this article when you no longer need them. You can delete the Azure resource group, which includes all the resources in the resource group.

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.

  2. On the Resource group page, select Delete. Enter the name of your resource group in the text box to confirm deletion, then select Delete.

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.

  2. On the Resource group page, select Delete. Enter the name of your resource group in the text box to confirm deletion, then select Delete.

7. Next steps

For more information, see the following articles: