Skip to content

Commit 8c5d9bc

Browse files
authored
Merge pull request #49256 from MicrosoftDocs/main
Sync main to optimize-costs-using-azure-hybrid-benefit
2 parents 3ba5755 + 950f86b commit 8c5d9bc

File tree

45 files changed

+733
-12
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+733
-12
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
### YamlMime:ModuleUnit
2+
uid: learn.java-on-azure-container-apps.1-introduction
3+
title: Introduction
4+
metadata:
5+
title: Introduction
6+
description: This unit introduces how to deploy a Spring Boot app to Azure Container Apps.
7+
author: KarlErickson
8+
ms.author: hangwan
9+
ms.date: 02/18/2025
10+
ms.topic: unit
11+
ms.custom:
12+
- team=cloud_advocates
13+
- devx-track-java
14+
- devx-track-extended-java
15+
ms.contributors: hangwan97
16+
durationInMinutes: 3
17+
content: |
18+
[!include[](includes/1-introduction.md)]
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
### YamlMime:ModuleUnit
2+
uid: learn.java-on-azure-container-apps.2-prepare-spring-boot-application
3+
title: Prepare Spring Boot application
4+
metadata:
5+
title: Prepare Spring Boot application
6+
description: Learn about application readiness before deploying to Azure Container Apps.
7+
author: KarlErickson
8+
ms.author: hangwan
9+
ms.date: 02/18/2025
10+
ms.topic: unit
11+
ms.custom:
12+
- team=cloud_advocates
13+
- devx-track-java
14+
- devx-track-extended-java
15+
ms.contributors: hangwan97
16+
durationInMinutes: 5
17+
content: |
18+
[!include[](includes/2-prepare-spring-boot-application.md)]
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
### YamlMime:ModuleUnit
2+
uid: learn.java-on-azure-container-apps.3-deploy-spring-boot-application
3+
title: Exercise - Deploy Spring Boot application
4+
metadata:
5+
title: Exercise - Deploy Spring Boot application
6+
description: This unit presents the deployment of the Spring Boot application to Azure Container Apps.
7+
author: KarlErickson
8+
ms.author: hangwan
9+
ms.date: 02/18/2025
10+
ms.topic: unit
11+
ms.custom:
12+
- team=cloud_advocates
13+
- devx-track-java
14+
- devx-track-extended-java
15+
ms.contributors: hangwan97
16+
durationInMinutes: 5
17+
content: |
18+
[!include[](includes/3-deploy-spring-boot-application.md)]
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
### YamlMime:ModuleUnit
2+
uid: learn.java-on-azure-container-apps.4-enhance-spring-boot-application
3+
title: Exercise - Maintain Spring Boot application
4+
metadata:
5+
title: Exercise - Maintain Spring Boot application
6+
description: In this unit, you use the built-in Java stack to enhance your Spring Boot application on Azure Container Apps.
7+
author: KarlErickson
8+
ms.author: hangwan
9+
ms.date: 02/18/2025
10+
ms.topic: unit
11+
ms.custom:
12+
- team=cloud_advocates
13+
- devx-track-java
14+
- devx-track-extended-java
15+
ms.contributors: hangwan97
16+
durationInMinutes: 6
17+
content: |
18+
[!include[](includes/4-enhance-spring-boot-application.md)]
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
### YamlMime:ModuleUnit
2+
uid: learn.java-on-azure-container-apps.5-connect-to-database
3+
title: Exercise - Connect to a database
4+
metadata:
5+
title: Exercise - Connect to a database
6+
description: This unit shows you how to connect your Spring Boot application to a database on Azure Container Apps.
7+
author: KarlErickson
8+
ms.author: hangwan
9+
ms.date: 02/18/2025
10+
ms.topic: unit
11+
ms.custom:
12+
- team=cloud_advocates
13+
- devx-track-java
14+
- devx-track-extended-java
15+
ms.contributors: hangwan97
16+
durationInMinutes: 5
17+
content: |
18+
[!include[](includes/5-connect-to-database.md)]
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
### YamlMime:ModuleUnit
2+
uid: learn.java-on-azure-container-apps.6-knowledge-check
3+
title: Knowledge check
4+
metadata:
5+
title: Knowledge check
6+
description: Check your knowledge of Java on Azure Container Apps.
7+
author: KarlErickson
8+
ms.author: hangwan
9+
ms.date: 02/18/2025
10+
ms.topic: unit
11+
ms.custom:
12+
- team=cloud_advocates
13+
- devx-track-java
14+
- devx-track-extended-java
15+
ms.contributors: hangwan97
16+
durationInMinutes: 3
17+
quiz:
18+
title: Check your knowledge
19+
questions:
20+
- content: "What is the purpose of setting the environment variable `spring.profiles.active` to `postgres` in the Azure Container Apps configuration?"
21+
choices:
22+
- content: "It enables Azure Container Apps to automatically connect to any available PostgreSQL database instance."
23+
isCorrect: false
24+
explanation: "Setting `spring.profiles.active` doesn't automatically connect to any PostgreSQL database. The database connection still needs to be configured manually."
25+
- content: "It activates a specific Spring profile that configures the application to use PostgreSQL instead of the default H2 database."
26+
isCorrect: true
27+
explanation: "This is correct. The `spring.profiles.active` variable activates the PostgreSQL configuration within the Spring application."
28+
- content: "It creates a new PostgreSQL database automatically if one isn't already specified."
29+
isCorrect: false
30+
explanation: "This is incorrect. Setting the profile doesn't create a new PostgreSQL database."
31+
- content: "It sets a default admin password for the PostgreSQL database."
32+
isCorrect: false
33+
explanation: "This answer is incorrect. The profile setting doesn't affect the PostgreSQL database password."
34+
- content: "What benefits does enabling the Java stack in Azure Container Apps provide for your Java applications?"
35+
choices:
36+
- content: "Automatic memory fitting tailored for Java applications, optimizing resource usage."
37+
isCorrect: false
38+
explanation: "The Java stack includes automatic memory fitting, but it isn't the only benefit."
39+
- content: "Access to built-in JVM metrics for tracking memory usage, garbage collection, and thread count."
40+
isCorrect: false
41+
explanation: "The Java stack provides JVM-level metrics that help monitor application health and performance, but it isn't the only benefit."
42+
- content: "Built-in Java diagnostics tools to monitor application health and performance."
43+
isCorrect: false
44+
explanation: "Built-in diagnostics tools are part of the Java stack, but it isn't the only benefit."
45+
- content: "All of the above."
46+
isCorrect: true
47+
explanation: "Correct. All of the listed features are benefits provided by the Java stack in Azure Container Apps."
48+
- content: "When deploying the Spring PetClinic application on Azure Container Apps, which resource is automatically set up to enable centralized logging and monitoring for the application?"
49+
choices:
50+
- content: "Azure Cosmos DB"
51+
isCorrect: false
52+
explanation: "Incorrect. Azure Cosmos DB is a database service and isn't automatically set up for logging or monitoring in Azure Container Apps."
53+
- content: "Log Analytics workspace"
54+
isCorrect: true
55+
explanation: "Correct. A Log Analytics workspace is automatically created during deployment to collect logs and monitor the application's performance."
56+
- content: "Azure Front Door"
57+
isCorrect: false
58+
explanation: "Incorrect. Azure Front Door is a global load balancer, and isn't automatically created when deploying applications in Azure Container Apps."
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
### YamlMime:ModuleUnit
2+
uid: learn.java-on-azure-container-apps.7-summary
3+
title: Summary
4+
metadata:
5+
title: Summary
6+
description: This unit introduces how to deploy Spring apps on Azure Container Apps.
7+
author: KarlErickson
8+
ms.author: hangwan
9+
ms.date: 02/18/2025
10+
ms.topic: unit
11+
ms.custom:
12+
- team=cloud_advocates
13+
- devx-track-java
14+
- devx-track-extended-java
15+
ms.contributors: hangwan97
16+
durationInMinutes: 3
17+
content: |
18+
[!include[](includes/7-summary.md)]
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
This module introduces Azure Container Apps, highlighting its Java support to help you identify the best deployment strategies for your Java applications. Many applications rely on Java workloads that enhance functionality and user experience. These applications range from simple services to complex microservice architectures. Azure provides a range of solutions for running Java applications, including Azure Container Apps, which has built-in support for Spring workloads. This support enables developers to easily deploy and manage Spring apps with features like automatic memory fitting, JVM monitoring, diagnostics, and seamless integration with Spring components such as Spring Cloud Service Registry and Spring Cloud Config Server. These capabilities empower teams to focus on building applications while Azure handles infrastructure complexities.
2+
3+
## Learning objectives
4+
5+
By the end of this module, you can do the following things:
6+
7+
- Launch your full-stack Java application on Azure Container Apps by using a Spring Boot web application with a PostgreSQL database.
8+
- Accelerate your Java applications using the built-in Java stack on Azure Container Apps.
9+
10+
## Prerequisites
11+
12+
- Familiarity with developing and running Java applications.
13+
- Beginner-level experience with cloud infrastructure.
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
In this unit, you learn how to prepare a Spring Boot application for deployment on Azure Container Apps. We use the popular Spring PetClinic sample application, which demonstrates the use of the Spring Framework and database access.
2+
3+
The Spring PetClinic is a simple web application that manages a list of veterinarians, their patients, and the visits those patients had. This application provides a practical way to understand key Spring Boot concepts while preparing a Spring Boot application for deployment to Azure.
4+
5+
## Prerequisites
6+
7+
- An Azure account. If you don't have one, [create an account for free](https://azure.microsoft.com/free/). You need the `Contributor` or `Owner` permission on the Azure subscription to proceed. For more information, see [Assign Azure roles using the Azure portal](/azure/role-based-access-control/role-assignments-portal).
8+
- [Git](https://git-scm.com/downloads)
9+
- [The Azure CLI](/cli/azure/install-azure-cli)
10+
11+
## Clone the PetClinic repository
12+
13+
To get started with the PetClinic application, clone the [Azure Container Apps Java Samples](https://github.com/Azure-Samples/azure-container-apps-java-samples) repository from GitHub by using the following command:
14+
15+
# [Bash](#tab/bash)
16+
17+
```bash
18+
git clone https://github.com/Azure-Samples/azure-container-apps-java-samples.git
19+
```
20+
21+
# [PowerShell](#tab/powershell)
22+
23+
```powershell
24+
git clone https://github.com/Azure-Samples/azure-container-apps-java-samples.git
25+
```
26+
27+
---
28+
29+
## Run the application locally
30+
31+
Before deploying the PetClinic application, ensure that it runs successfully on your local machine by using the following steps:
32+
33+
1. Navigate to the project directory by using the following command:
34+
35+
# [Bash](#tab/bash)
36+
37+
```bash
38+
cd azure-container-apps-java-samples/spring-petclinic/spring-petclinic/
39+
```
40+
41+
# [PowerShell](#tab/powershell)
42+
43+
```powershell
44+
cd azure-container-apps-java-samples/spring-petclinic/spring-petclinic/
45+
```
46+
47+
---
48+
49+
1. Initialize and update the `pet-clinic` Git submodule to the latest version by using the following command:
50+
51+
# [Bash](#tab/bash)
52+
53+
```bash
54+
git submodule update --init --recursive
55+
```
56+
57+
# [PowerShell](#tab/powershell)
58+
59+
```powershell
60+
git submodule update --init --recursive
61+
```
62+
63+
---
64+
65+
1. Build the project by using the following Maven command:
66+
67+
# [Bash](#tab/bash)
68+
69+
```bash
70+
./mvnw clean install
71+
```
72+
73+
# [PowerShell](#tab/powershell)
74+
75+
```powershell
76+
./mvnw clean install
77+
```
78+
79+
---
80+
81+
1. Run the application by using the following command:
82+
83+
# [Bash](#tab/bash)
84+
85+
```bash
86+
./mvnw spring-boot:run
87+
```
88+
89+
# [PowerShell](#tab/powershell)
90+
91+
```powershell
92+
./mvnw spring-boot:run
93+
```
94+
95+
---
96+
97+
1. After the application is running, you can access it locally via `http://localhost:8080`. You should see the Spring PetClinic interface, as shown in the following screenshot:
98+
99+
:::image type="content" source="../media/pet-clinic.png" alt-text="Screenshot of the home page of the PetClinic application." lightbox="../media/pet-clinic.png":::
100+
101+
## Database configuration
102+
103+
By default, the PetClinic application uses an in-memory H2 database that's automatically populated with data during startup. The H2 console is accessible at [http://localhost:8080/h2-console](http://localhost:8080/h2-console), enabling you to inspect the database content via the URL `jdbc:h2:mem:<UUID>`. The specific UUID is displayed in the console when the application starts.

0 commit comments

Comments
 (0)