Skip to content

Commit 360297a

Browse files
authored
Merge pull request #231428 from KarlErickson/consumption_plan_quickstart
Release PR for "Update quickstart.md #228459"
2 parents e20dcb6 + 22a46c4 commit 360297a

File tree

2 files changed

+199
-38
lines changed

2 files changed

+199
-38
lines changed
82.6 KB
Loading

articles/spring-apps/quickstart.md

Lines changed: 199 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
title: "Quickstart - Deploy your first application to Azure Spring Apps"
33
description: Describes how to deploy an application to Azure Spring Apps.
44
author: karlerickson
5+
ms.author: karler
56
ms.service: spring-apps
67
ms.topic: quickstart
7-
ms.date: 08/22/2022
8-
ms.author: karler
8+
ms.date: 03/21/2022
99
ms.custom: devx-track-java, devx-track-azurecli, mode-other, event-tier1-build-2022, engagement-fy23
1010
---
1111

@@ -17,11 +17,11 @@ ms.custom: devx-track-java, devx-track-azurecli, mode-other, event-tier1-build-2
1717
> [!NOTE]
1818
> 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.
1919
20-
**This article applies to:** ✔️ Basic/Standard tier ✔️ Enterprise tier
20+
**This article applies to:** ✔️ Standard consumption (Preview) ✔️ Basic/Standard ✔️ Enterprise
2121

22-
This quickstart explains how to deploy a small application to run on Azure Spring Apps.
22+
This article explains how to deploy a small application to run on Azure Spring Apps.
2323

24-
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.
24+
The application code used in this tutorial is a simple app. When you've completed this example, the application is accessible online, and you can manage it through the Azure portal.
2525

2626
This quickstart explains how to:
2727

@@ -32,27 +32,28 @@ This quickstart explains how to:
3232
> - Build and deploy an app with a public endpoint.
3333
> - Clean up the resources.
3434
35-
At the end of this quickstart, you'll have a working spring app running on Azure Spring Apps.
35+
At the end of this quickstart, you have a working spring app running on Azure Spring Apps.
3636

3737
## [Azure CLI](#tab/Azure-CLI)
3838

3939
## Prerequisites
4040

4141
- An Azure subscription. If you don't have a subscription, create a [free account](https://azure.microsoft.com/free/) before you begin.
42+
- [Apache Maven](https://maven.apache.org/download.cgi)
4243
- [Azure CLI](/cli/azure/install-azure-cli). Install the Azure Spring Apps extension with the following command: `az extension add --name spring`
4344
- If you're deploying Azure Spring Apps Enterprise tier for the first time in the target subscription, see the [Prerequisites](./how-to-enterprise-marketplace-offer.md#prerequisites) section of [View Azure Spring Apps Enterprise tier offering in Azure Marketplace](./how-to-enterprise-marketplace-offer.md).
4445

4546
## Provision an instance of Azure Spring Apps
4647

47-
Use the following steps to provision a service instance.
48+
Use the following steps to create an Azure Spring Apps service instance.
4849

49-
1. Select **Try It** and sign in to your Azure account in [Azure Cloud Shell](../cloud-shell/overview.md).
50+
1. Select **Open Cloudshell** and sign in to your Azure account in [Azure Cloud Shell](../cloud-shell/overview.md).
5051

5152
```azurecli-interactive
5253
az account show
5354
```
5455

55-
1. Azure Cloud Shell workspaces are temporary. On initial start, the shell prompts you to associate an [Azure Storage](../storage/common/storage-introduction.md) instance with your subscription to persist files across sessions.
56+
1. Azure Cloud Shell workspaces are temporary. When first started, the shell prompts you to select an [Azure Storage](../storage/common/storage-introduction.md) instance with your subscription to persist files across sessions.
5657

5758
:::image type="content" source="media/quickstart/azure-storage-subscription.png" alt-text="Screenshot of Azure Storage subscription." lightbox="media/quickstart/azure-storage-subscription.png":::
5859

@@ -62,7 +63,7 @@ Use the following steps to provision a service instance.
6263
az account list --output table
6364
```
6465

65-
1. Use the following command to choose and link to your subscription.
66+
1. Use the following command to set your default subscription.
6667

6768
```azurecli-interactive
6869
az account set --subscription <subscription-id>
@@ -81,19 +82,23 @@ Use the following steps to provision a service instance.
8182
```azurecli-interactive
8283
az spring create \
8384
--resource-group <name-of-resource-group> \
84-
--name <service-instance-name>
85+
--name <Azure-Spring-Apps-instance-name>
8586
```
8687

87-
1. Choose **Y** to install the Azure Spring Apps extension and run it.
88+
1. Select **Y** to install the Azure Spring Apps extension and run it.
8889

8990
## Create an app in your Azure Spring Apps instance
9091

91-
Use the following command to specify the app name on Azure Spring Apps as *hellospring*.
92+
An [*App*](concept-understand-app-and-deployment.md) is an abstraction of one business app. Apps run in an Azure Spring Apps service instance, as shown in the following diagram.
93+
94+
:::image type="content" source="media/spring-cloud-app-and-deployment/app-deployment-rev.png" alt-text="Diagram showing the relationship between apps and an Azure Spring Apps service instance.":::
95+
96+
Use the following command to specify the app name on Azure Spring Apps as *hello spring*.
9297

9398
```azurecli-interactive
9499
az spring app create \
95100
--resource-group <name-of-resource-group> \
96-
--service <service-instance-name> \
101+
--service <Azure-Spring-Apps-instance-name> \
97102
--name hellospring \
98103
--assign-endpoint true
99104
```
@@ -127,13 +132,170 @@ Use the following command to deploy the *.jar* file for the app (*target/spring-
127132
```azurecli-interactive
128133
az spring app deploy \
129134
--resource-group <name-of-resource-group> \
130-
--service <service-instance-name> \
135+
--service <Azure-Spring-Apps-instance-name> \
131136
--name hellospring \
132137
--artifact-path target/spring-boot-complete-0.0.1-SNAPSHOT.jar
133138
```
134139

135140
Deploying the application can take a few minutes.
136141

142+
## [Standard consumption plan](#tab/Consumption-Plan)
143+
144+
## Prerequisites
145+
146+
- An Azure subscription. If you don't have a subscription, create a [free account](https://azure.microsoft.com/free/) before you begin.
147+
- [Apache Maven](https://maven.apache.org/download.cgi)
148+
- [Azure CLI](/cli/azure/install-azure-cli). Install the spring extension for `StandardGen2` Azure Spring Apps by using the following command.
149+
150+
```shell
151+
az extension add --upgrade --name spring
152+
```
153+
154+
- Use the following commands to install the Azure Container Apps extension for the Azure CLI and register these namespaces: `Microsoft.App`, `Microsoft.OperationalInsights`, and `Microsoft.AppPlatform`
155+
156+
```shell
157+
az extension add --name containerapp --upgrade
158+
az provider register --namespace Microsoft.App
159+
az provider register --namespace Microsoft.OperationalInsights
160+
az provider register --namespace Microsoft.AppPlatform
161+
```
162+
163+
## Provision an instance of Azure Spring Apps
164+
165+
Use the following steps to create an Azure Spring Apps service instance.
166+
167+
1. Select **Open Cloudshell** and sign in to your Azure account in [Azure Cloud Shell](../cloud-shell/overview.md).
168+
169+
```azurecli-interactive
170+
az account show
171+
```
172+
173+
1. Azure Cloud Shell workspaces are temporary. When first started, the shell prompts you to associate an [Azure Storage](../storage/common/storage-introduction.md) instance with your subscription to persist files across sessions.
174+
175+
:::image type="content" source="media/quickstart/azure-storage-subscription.png" alt-text="Screenshot of Azure Storage subscription." lightbox="media/quickstart/azure-storage-subscription.png":::
176+
177+
1. After you sign in successfully, use the following command to display a list of your subscriptions.
178+
179+
```azurecli-interactive
180+
az account list --output table
181+
```
182+
183+
1. Use the following command to set your default subscription.
184+
185+
```azurecli-interactive
186+
az account set --subscription <subscription-id>
187+
```
188+
189+
1. Define variables for this quickstart with the names of your resources and desired settings.
190+
191+
```azurecli-interactive
192+
LOCATION="<region>"
193+
RESOURCE_GROUP="<resource-group-name>"
194+
MANAGED_ENVIRONMENT="<Azure-Container-Apps-environment-name>"
195+
SERVICE_NAME="<Azure-Spring-Apps-instance-name>"
196+
APP_NAME="<Spring-app-name>"
197+
```
198+
199+
1. Use the following command to create a resource group.
200+
201+
```azurecli-interactive
202+
az group create \
203+
--resource-group ${RESOURCE_GROUP} \
204+
--location ${LOCATION}
205+
```
206+
207+
1. An Azure Container App environment creates a secure boundary around a group of applications. Apps deployed to the same environment are deployed in the same virtual network and write logs to the same [Log Analytics workspace](/azure/azure-monitor/logs/log-analytics-workspace-overview). To create the environment, run the following command:
208+
209+
```azurecli-interactive
210+
az containerapp env create \
211+
--name ${MANAGED_ENVIRONMENT} \
212+
--resource-group ${RESOURCE_GROUP} \
213+
--location ${LOCATION}
214+
```
215+
216+
1. Use the following command to create a variable to store the environment resource ID:
217+
218+
```azurecli-interactive
219+
MANAGED_ENV_RESOURCE_ID=$(az containerapp env show \
220+
--name ${MANAGED_ENVIRONMENT} \
221+
--resource-group ${RESOURCE_GROUP} \
222+
--query id \
223+
--output tsv)
224+
```
225+
226+
1. Use the following command to create an Azure Spring Apps service instance. The `StandardGen2` Azure Spring Apps instance is built on top of the Azure Container Apps environment. Create your Azure Spring Apps instance by specifying the resource ID of the environment you created.
227+
228+
```azurecli-interactive
229+
az spring create \
230+
--resource-group ${RESOURCE_GROUP} \
231+
--name ${SERVICE_NAME} \
232+
--managed-environment ${MANAGED_ENV_RESOURCE_ID} \
233+
--sku standardGen2 \
234+
--location ${LOCATION}
235+
```
236+
237+
## Create an app in your Azure Spring Apps instance
238+
239+
An [*App*](/azure/spring-apps/concept-understand-app-and-deployment) is an abstraction of one business app. Apps run in an Azure Spring Apps service instance, or simply service instance, as shown in the following diagram.
240+
241+
:::image type="content" source="media/spring-cloud-app-and-deployment/app-deployment-rev.png" alt-text="Diagram showing the relationship between apps and an Azure Spring Apps service instance.":::
242+
243+
Use the following command to specify the app name on Azure Spring Apps and to allocate required resources:
244+
245+
```azurecli-interactive
246+
az spring app create \
247+
--resource-group ${RESOURCE_GROUP} \
248+
--service ${SERVICE_NAME} \
249+
--name ${APP_NAME} \
250+
--cpu 1 \
251+
--memory 2Gi \
252+
--instance-count 2 \
253+
--assign-endpoint true
254+
```
255+
256+
Azure Spring Apps creates an empty welcome application and provides its URL in the field named `properties.url`.
257+
258+
:::image type="content" source="media/quickstart/app-welcome-page.png" alt-text="Screenshot of the welcome page." lightbox="media/quickstart/app-welcome-page.png":::
259+
260+
## Clone and build the Spring Boot sample project
261+
262+
Use the following steps to clone the Spring Boot sample project.
263+
264+
1. Use the following command to clone the [Spring Boot sample project](https://github.com/spring-guides/gs-spring-boot.git) from GitHub.
265+
266+
```azurecli-interactive
267+
git clone -b boot-2.7 https://github.com/spring-guides/gs-spring-boot.git
268+
```
269+
270+
1. Use the following command to move to the project folder.
271+
272+
```azurecli-interactive
273+
cd gs-spring-boot/complete
274+
```
275+
276+
1. Use the following [Maven](https://maven.apache.org/what-is-maven.html) command to build the project.
277+
278+
```azurecli-interactive
279+
mvn clean package -DskipTests
280+
```
281+
282+
## Deploy the local app to Azure Spring Apps
283+
284+
Use the following command to deploy the *.jar* file for the app.
285+
286+
```azurecli-interactive
287+
az spring app deploy \
288+
--resource-group ${RESOURCE_GROUP} \
289+
--service ${SERVICE_NAME} \
290+
--name ${APP_NAME} \
291+
--artifact-path target/spring-boot-complete-0.0.1-SNAPSHOT.jar \
292+
--env testEnvKey=testEnvValue \
293+
--runtime-version Java_11 \
294+
--jvm-options '-Xms1024m -Xmx2048m'
295+
```
296+
297+
Deploying the application can take a few minutes.
298+
137299
## [IntelliJ](#tab/IntelliJ)
138300

139301
## Prerequisites
@@ -149,37 +311,36 @@ Use the following steps to create the project:
149311

150312
1. Use [Spring Initializr](https://start.spring.io/#!type=maven-project&language=java&platformVersion=2.6.10&packaging=jar&jvmVersion=11&groupId=com.example&artifactId=hellospring&name=hellospring&description=Demo%20project%20for%20Spring%20Boot&packageName=com.example.hellospring&dependencies=web,cloud-eureka,actuator,cloud-config-client) to generate a sample project with recommended dependencies for Azure Spring Apps. The following URL provides default settings for you.
151313

152-
```url
153-
https://start.spring.io/#!type=maven-project&language=java&platformVersion=2.6.10&packaging=jar&jvmVersion=11&groupId=com.example&artifactId=hellospring&name=hellospring&description=Demo%20project%20for%20Spring%20Boot&packageName=com.example.hellospring&dependencies=web,cloud-eureka,actuator,cloud-config-client
154-
```
314+
```url
315+
https://start.spring.io/#!type=maven-project&language=java&platformVersion=2.6.10&packaging=jar&jvmVersion=11&groupId=com.example&artifactId=hellospring&name=hellospring&description=Demo%20project%20for%20Spring%20Boot&packageName=com.example.hellospring&dependencies=web,cloud-eureka,actuator,cloud-config-client
316+
```
155317

156-
The following image shows the recommended Initializr settings for the *hellospring* sample project.
318+
The following image shows the recommended Initializr settings for the *hellospring* sample project.
157319

158-
This example uses Java version 11. To use a different Java version, change the Java version setting under **Project Metadata**.
320+
This example uses Java version 11. To use a different Java version, change the Java version setting under **Project Metadata**.
159321

160-
:::image type="content" source="media/quickstart/initializr-page.png" alt-text="Screenshot of Spring Initializr page." lightbox="media/quickstart/initializr-page.png":::
322+
:::image type="content" source="media/quickstart/initializr-page.png" alt-text="Screenshot of Spring Initializr page." lightbox="media/quickstart/initializr-page.png":::
161323

162324
1. When all dependencies are set, select **Generate**.
163325
1. Download and unpack the package, and then create a web controller for your web application by adding the file *src/main/java/com/example/hellospring/HelloController.java* with the following contents:
164326

165-
```java
166-
package com.example.hellospring;
327+
```java
328+
package com.example.hellospring;
167329

168-
import org.springframework.web.bind.annotation.RestController;
169-
import org.springframework.web.bind.annotation.RequestMapping;
330+
import org.springframework.web.bind.annotation.RestController;
331+
import org.springframework.web.bind.annotation.RequestMapping;
170332

171-
@RestController
172-
public class HelloController {
333+
@RestController
334+
public class HelloController {
173335

174-
@RequestMapping("/")
175-
public String index() {
176-
return "Greetings from Azure Spring Apps!";
336+
@RequestMapping("/")
337+
public String index() {
338+
return "Greetings from Azure Spring Apps!";
177339
}
340+
}
341+
```
178342

179-
}
180-
```
181-
182-
## Provision an instance of Azure Spring Apps
343+
## Create an instance of Azure Spring Apps
183344

184345
Use the following steps to create an instance of Azure Spring Apps using the Azure portal.
185346

@@ -195,11 +356,11 @@ Use the following steps to create an instance of Azure Spring Apps using the Azu
195356

196357
:::image type="content" source="media/quickstart/spring-apps-create.png" alt-text="Screenshot of Azure portal showing Azure Spring Apps resource with Create button highlighted." lightbox="media/quickstart/spring-apps-create.png":::
197358

198-
1. Fill out the form on the Azure Spring Apps **Create** page. Consider the following guidelines:
359+
1. Fill out the form on the Azure Spring Apps **Create** page. Consider the following guidelines:
199360

200361
- **Subscription**: Select the subscription you want to be billed for this resource.
201362
- **Resource group**: Creating new resource groups for new resources is a best practice.
202-
- **Service Name**: Specify the service instance name. You'll use this name later in this article where the *\<service-instance-name\>* placeholder appears. 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.
363+
- **Service Name**: Specify the service instance name. You use this name later in this article where the *\<Azure-Spring-Apps-instance-name\>* placeholder appears. 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.
203364
- **Region**: Select the region for your service instance.
204365

205366
:::image type="content" source="media/quickstart/portal-start.png" alt-text="Screenshot of Azure portal showing Azure Spring Apps Create page." lightbox="media/quickstart/portal-start.png":::
@@ -280,9 +441,9 @@ echo "Press [ENTER] to continue ..."
280441

281442
## Next steps
282443

283-
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.
444+
In this quickstart, you learned how to build and deploy a Spring app in an Azure Spring Apps service instance. You also learned how to deploy an app with a public endpoint, and how to clean up resources.
284445

285-
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](./quickstart-logs-metrics-tracing.md).
446+
You 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](./quickstart-logs-metrics-tracing.md).
286447

287448
To learn how to use more Azure Spring capabilities, advance to the quickstart series that deploys a sample application to Azure Spring Apps:
288449

0 commit comments

Comments
 (0)