You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/spring-apps/quickstart.md
+253-1Lines changed: 253 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -197,7 +197,259 @@ Deploying the application can take a few minutes.
197
197
198
198
::: zone-end
199
199
200
-
::: zone pivot="sc-basic-standard-enterprise"
200
+
::: zone pivot="sc-standard"
201
+
This article explains how to deploy a small application to run on Azure Spring Apps.
202
+
203
+
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.
204
+
205
+
This quickstart explains how to:
206
+
207
+
> [!div class="checklist"]
208
+
209
+
> - Generate a basic Spring project.
210
+
> - Provision a service instance.
211
+
> - Build and deploy an app with a public endpoint.
212
+
> - Clean up the resources.
213
+
214
+
At the end of this quickstart, you have a working Spring app running on Azure Spring Apps.
215
+
216
+
## [Azure CLI](#tab/Azure-CLI)
217
+
218
+
## Prerequisites
219
+
220
+
- An Azure subscription. If you don't have a subscription, create a [free account](https://azure.microsoft.com/free/) before you begin.
-[Azure CLI](/cli/azure/install-azure-cli). Install the Azure Spring Apps extension with the following command: `az extension add --name spring`
223
+
- 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).
224
+
225
+
## Provision an instance of Azure Spring Apps
226
+
227
+
Use the following steps to create an Azure Spring Apps service instance.
228
+
229
+
1. Select **Open Cloudshell** and sign in to your Azure account in [Azure Cloud Shell](../cloud-shell/overview.md).
230
+
231
+
```azurecli-interactive
232
+
az account show
233
+
```
234
+
235
+
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.
236
+
237
+
:::image type="content" source="media/quickstart/azure-storage-subscription.png" alt-text="Screenshot of Azure Storage subscription." lightbox="media/quickstart/azure-storage-subscription.png":::
238
+
239
+
1. After you sign in successfully, use the following command to display a list of your subscriptions.
240
+
241
+
```azurecli-interactive
242
+
az account list --output table
243
+
```
244
+
245
+
1. Use the following command to set your default subscription.
246
+
247
+
```azurecli-interactive
248
+
az account set --subscription <subscription-ID>
249
+
```
250
+
251
+
1. Use the following command to create a resource group.
252
+
253
+
```azurecli-interactive
254
+
az group create \
255
+
--resource-group <name-of-resource-group> \
256
+
--location eastus
257
+
```
258
+
259
+
1. Use the following command to create an Azure Spring Apps service instance.
260
+
261
+
```azurecli-interactive
262
+
az spring create \
263
+
--resource-group <name-of-resource-group> \
264
+
--name <Azure-Spring-Apps-instance-name>
265
+
```
266
+
267
+
1. Select **Y** to install the Azure Spring Apps extension and run it.
268
+
269
+
## Create an app in your Azure Spring Apps instance
270
+
271
+
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.
272
+
273
+
:::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.":::
274
+
275
+
Use the following command to specify the app name on Azure Spring Apps as *hellospring*.
276
+
277
+
```azurecli-interactive
278
+
az spring app create \
279
+
--resource-group <name-of-resource-group> \
280
+
--service <Azure-Spring-Apps-instance-name> \
281
+
--name hellospring \
282
+
--assign-endpoint true
283
+
```
284
+
285
+
## Clone and build the Spring Boot sample project
286
+
287
+
Use the following steps to clone the Spring Boot sample project.
288
+
289
+
1. Use the following command to clone the [Spring Boot sample project](https://github.com/spring-guides/gs-spring-boot.git) from GitHub.
-[Azure Toolkit for IntelliJ](/azure/developer/java/toolkit-for-intellij/install-toolkit).
328
+
- 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).
329
+
330
+
## Generate a Spring project
331
+
332
+
Use the following steps to create the project:
333
+
334
+
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.
The following image shows the recommended Initializr settings for the *hellospring* sample project.
341
+
342
+
This example uses Java version 11. To use a different Java version, change the Java version setting under **Project Metadata**.
343
+
344
+
:::image type="content" source="media/quickstart/initializr-page.png" alt-text="Screenshot of Spring Initializr page." lightbox="media/quickstart/initializr-page.png":::
345
+
346
+
1. When all dependencies are set, select **Generate**.
347
+
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:
Use the following steps to create an instance of Azure Spring Apps using the Azure portal.
368
+
369
+
1. In a new tab, open the [Azure portal](https://portal.azure.com/).
370
+
371
+
1. From the top search box, search for **Azure Spring Apps**.
372
+
373
+
1. Select **Azure Spring Apps** from the results.
374
+
375
+
:::image type="content" source="media/quickstart/spring-apps-start.png" alt-text="Screenshot of Azure portal showing Azure Spring Apps service in search results." lightbox="media/quickstart/spring-apps-start.png":::
376
+
377
+
1. On the Azure Spring Apps page, select **Create**.
378
+
379
+
:::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":::
380
+
381
+
1. Fill out the form on the Azure Spring Apps **Create** page. Consider the following guidelines:
382
+
383
+
-**Subscription**: Select the subscription you want to be billed for this resource.
384
+
-**Resource group**: Creating new resource groups for new resources is a best practice.
385
+
-**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.
386
+
-**Region**: Select the region for your service instance.
387
+
388
+
:::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":::
389
+
390
+
1. Select **Review and create**.
391
+
392
+
## Import the project
393
+
394
+
Use the following steps to import the project.
395
+
396
+
1. Open IntelliJ IDEA, and then select **Open**.
397
+
1. In the **Open File or Project** dialog box, select the *hellospring* folder.
398
+
399
+
:::image type="content" source="media/quickstart/intellij-new-project.png" alt-text="Screenshot of IntelliJ IDEA showing Open File or Project dialog box." lightbox="media/quickstart/intellij-new-project.png":::
400
+
401
+
## Build and deploy your app
402
+
403
+
> [!NOTE]
404
+
> To run the project locally, add `spring.config.import=optional:configserver:` to the project's *application.properties* file.
405
+
406
+
Use the following steps to build and deploy your app.
407
+
408
+
1. If you haven't already installed the Azure Toolkit for IntelliJ, follow the steps in [Install the Azure Toolkit for IntelliJ](/azure/developer/java/toolkit-for-intellij/install-toolkit).
409
+
410
+
1. Right-click your project in the IntelliJ Project window, and then select **Azure** -> **Deploy to Azure Spring Apps**.
411
+
412
+
:::image type="content" source="media/quickstart/intellij-deploy-azure.png" alt-text="Screenshot of IntelliJ IDEA menu showing Deploy to Azure Spring Apps option." lightbox="media/quickstart/intellij-deploy-azure.png":::
413
+
414
+
1. 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.
415
+
1. In the **Artifact** textbox, select **Maven:com.example:hellospring-0.0.1-SNAPSHOT**.
416
+
1. In the **Subscription** textbox, verify that your subscription is correct.
417
+
1. In the **Service** textbox, select the instance of Azure Spring Apps that you created in [Provision an instance of Azure Spring Apps](#provision-an-instance-of-azure-spring-apps-1).
418
+
1. In the **App** textbox, select the plus sign (**+**) to create a new app.
419
+
420
+
:::image type="content" source="media/quickstart/intellij-create-new-app.png" alt-text="Screenshot of IntelliJ IDEA showing Deploy Azure Spring Apps dialog box." lightbox="media/quickstart/intellij-create-new-app.png":::
421
+
422
+
1. In the **App name:** textbox under **App Basics**, enter *hellospring*, and then select the **More settings** check box.
423
+
1. Select the **Enable** button next to **Public endpoint**. The button changes to **Disable \<to be enabled\>**.
424
+
1. If you're using Java 11, select **Java 11** for the **Runtime** option.
425
+
1. Select **OK**.
426
+
427
+
:::image type="content" source="media/quickstart/intellij-more-settings.png" alt-text="Screenshot of IntelliJ IDEA Create Azure Spring Apps dialog box with public endpoint Disable button highlighted." lightbox="media/quickstart/intellij-more-settings.png":::
428
+
429
+
1. Under **Before launch**, select **Run Maven Goal 'hellospring:package'**, and then select the pencil icon to edit the command line.
430
+
431
+
:::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":::
432
+
433
+
1. In the **Command line** textbox, enter *-DskipTests* after *package*, and then select **OK**.
434
+
435
+
:::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":::
436
+
437
+
1. To start the deployment, select the **Run** button at the bottom of the **Deploy Azure Spring Apps app** dialog box. The plug-in runs the command `mvn package -DskipTests` on the `hellospring` app and deploys the *.jar* file generated by the `package` command.
438
+
439
+
## [Visual Studio Code](#tab/VS-Code)
440
+
441
+
## Prerequisites
442
+
443
+
- 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).
444
+
445
+
## Deploy a Spring Boot web app to Azure Spring Apps with Visual Studio Code
446
+
447
+
To deploy a Spring Boot web app to Azure Spring Apps, follow the steps in [Java on Azure Spring Apps](https://code.visualstudio.com/docs/java/java-spring-apps).
448
+
449
+
---
450
+
::: zone-end
451
+
452
+
::: zone pivot="sc-enterprise"
201
453
This article explains how to deploy a small application to run on Azure Spring Apps.
202
454
203
455
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.
0 commit comments