Quickstart: Deploy your first application to Azure Spring Apps
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.
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.
- An Azure subscription. If you don't have a subscription, create a free account before you begin.
- Azure CLI. Install the Azure Spring Apps extension with the following command:
az extension add --name spring
- If you're deploying Azure Spring Apps Enterprise tier for the first time in the target subscription, see the Prerequisites section of View Azure Spring Apps Enterprise tier offering in Azure Marketplace.
Provision an instance of Azure Spring Apps
Use the following steps to provision a service instance.
Select Try It and sign in to your Azure account in Azure Cloud Shell.
az account show
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.
After you sign in successfully, use the following command to display a list of your subscriptions.
az account list --output table
Use the following command to choose and link to your subscription.
az account set --subscription <subscription-id>
Use the following command to create a resource group.
az group create \ --resource-group <name-of-resource-group> \ --location eastus
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>
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.
Use the following command to clone the Spring Boot sample project from GitHub.
git clone https://github.com/spring-guides/gs-spring-boot.git
Use the following command to move to the project folder.
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 ..."
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.
Indsend og få vist feedback om