Skip to content

Latest commit

 

History

History
282 lines (171 loc) · 11.1 KB

File metadata and controls

282 lines (171 loc) · 11.1 KB
author karlerickson
ms.author v-shilichen
ms.service azure-spring-apps
ms.custom devx-track-azurecli
ms.topic include
ms.date 08/19/2025
ms.update-cycle 1095-days

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.

[!INCLUDE prepare-spring-project]

[!INCLUDE prepare-spring-project]

[!INCLUDE generate-spring-project]

To prepare the Spring project, follow the steps in the Before you begin section of Java on Azure Spring Apps.


3. Prepare the cloud environment

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

[!INCLUDE hello-prepare-cloud-environment-enterprise-azure-portal]

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 an Azure Spring Apps instance

[!INCLUDE provision-enterprise-azure-spring-apps]

3.1. Provide names for each resource

Create variables to hold the resource names by using the following commands. Be sure to replace the placeholders with your own values.

export LOCATION="<region>"
export RESOURCE_GROUP="<resource-group-name>"
export SERVICE_NAME="<Azure-Spring-Apps-instance-name>"
export APP_NAME="demo"

3.2. Create a new resource group

Use the following steps to create a new resource group:

  1. Use the following command to sign in to the Azure CLI:

    az login
    
  2. Use the following command to set the default location:

    az configure --defaults location=${LOCATION}
    
  3. Use the following command to list all available subscriptions to determine the subscription ID to use:

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

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

    az group create --resource-group ${RESOURCE_GROUP}
    
  6. Use the following command to set the newly created resource group as the default resource group:

    az configure --defaults group=${RESOURCE_GROUP}
    

3.3. Install extension and register namespace

Use the following commands to install the Azure Spring Apps extension for the Azure CLI and register the namespace: Microsoft.SaaS:

az extension add --name spring --upgrade
az provider register --namespace Microsoft.SaaS

3.4. Create an Azure Spring Apps instance

Use the following steps to create the service instance:

  1. Use the following command to accept the legal terms and privacy statements for the Enterprise plan:

    [!NOTE] This step is necessary only if your subscription has never been used to create an Enterprise plan instance of Azure Spring Apps.

    az term accept \
        --publisher vmware-inc \
        --product azure-spring-cloud-vmware-tanzu-2 \
        --plan asa-ent-hr-mtr
    
  2. Use the following command to create an Azure Spring Apps service instance:

    az spring create \
        --name ${SERVICE_NAME} \
        --sku Enterprise
    

3.5. Create an app in your Azure Spring Apps instance

An App is an abstraction of one business app. For more information, see App and deployment in Azure Spring Apps. Apps run in an Azure Spring Apps service instance, as shown in the following diagram.

:::image type="content" source="../../media/quickstart/app-deployment-diagram.png" alt-text="Diagram that shows the relationship between apps and an Azure Spring Apps service instance." border="false":::

Use the following command to create the app on Azure Spring Apps:

az spring app create \
    --service ${SERVICE_NAME} \
    --name ${APP_NAME} \
    --assign-endpoint true

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

[!INCLUDE provision-enterprise-azure-spring-apps]

To create an Azure Spring Apps instance, follow the steps in the Create an app on Azure Spring Apps section of Java on Azure Spring Apps.


4. Deploy the app to Azure Spring Apps

[!INCLUDE deploy-hello-app-azure-portal]

[!INCLUDE deploy-spring-apps-maven-plugin]

  1. Use the following command to deploy the app:

    ./mvnw azure-spring-apps:deploy

    The following list describes the command interaction:

    • OAuth2 login: You need to authorize the sign in to Azure based on the OAuth2 protocol.

    After the command is executed, you can see from the following log messages that the deployment was successful:

    [INFO] Deployment(default) is successfully created
    [INFO] Starting Spring App after deploying artifacts...
    [INFO] Deployment Status: Running
    [INFO]   InstanceName:demo-default-x-xxxxxxxxxx-xxxxx  Status:Running Reason:null       DiscoverStatus:N/A
    [INFO] Getting public url of app(demo)...
    [INFO] Application url: https://<your-Azure-Spring-Apps-instance-name>-demo.azuremicroservices.io
    

Use the following command to deploy the .jar file for the app:

az spring app deploy \
    --service ${SERVICE_NAME} \
    --name ${APP_NAME} \
    --artifact-path target/demo-0.0.1-SNAPSHOT.jar

Deploying the application can take a few minutes.

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.

    :::image type="content" source="../../media/quickstart/intellij-new-project.png" alt-text="Screenshot of IntelliJ IDEA that shows the Open File or Project dialog box." lightbox="../../media/quickstart/intellij-new-project.png":::

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.

    :::image type="content" source="../../media/quickstart/intellij-deploy-azure.png" alt-text="Screenshot of the IntelliJ IDEA menu that shows the Deploy to Azure Spring Apps option." lightbox="../../media/quickstart/intellij-deploy-azure.png":::

  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.

    :::image type="content" source="../../media/quickstart/intellij-create-new-app.png" alt-text="Screenshot of the IntelliJ IDEA that shows the Deploy Azure Spring Apps dialog box." lightbox="../../media/quickstart/intellij-create-new-app.png":::

  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.

    :::image type="content" source="../../media/quickstart/intellij-more-settings.png" alt-text="Screenshot of IntelliJ IDEA Create app dialog box with public endpoint Disable button highlighted." lightbox="../../media/quickstart/intellij-more-settings.png":::

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

    :::image type="content" source="../../media/quickstart/intellij-edit-maven-goal.png" alt-text="Screenshot of IntelliJ IDEA Create Azure Spring Apps dialog box with Maven Goal edit button highlighted." lightbox="../../media/quickstart/intellij-edit-maven-goal.png":::

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

    :::image type="content" source="../../media/quickstart/intellij-maven-goal-command-line.png" alt-text="Screenshot of IntelliJ IDEA Select Maven Goal dialog box with Command Line value highlighted." lightbox="../../media/quickstart/intellij-maven-goal-command-line.png":::

  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.

To deploy the app to Azure Spring Apps, follow the steps in the Build and deploy the app section of Java on Azure Spring Apps.