Skip to content

Commit cf62d57

Browse files
authored
Merge pull request #276696 from Caoxuyang/xuyang/sba-doc
Add doc for Admin for Spring
2 parents d032852 + 2d5fabb commit cf62d57

File tree

11 files changed

+678
-8
lines changed

11 files changed

+678
-8
lines changed

articles/container-apps/TOC.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,8 @@
361361
displayName: java
362362
- name: Use Eureka Server for Spring
363363
href: java-eureka-server-usage.md
364+
- name: Use Admin for Spring
365+
href: java-admin-for-spring-usage.md
364366
- name: Use Config Server for Spring
365367
href: java-config-server-usage.md
366368
displayName: java
@@ -371,9 +373,14 @@
371373
items:
372374
- name: Connect to Eureka Server for Spring
373375
href: java-eureka-server.md
376+
- name: Connect to Admin for Spring
377+
href: java-admin.md
374378
- name: Connect to Config Server for Spring
375379
href: java-config-server.md
376380
displayName: java
381+
- name: Integrate Eureka Server with Admin for Spring
382+
href: java-admin-eureka-integration.md
383+
displayName: java
377384
- name: Query managed component logs
378385
href: java-component-logs.md
379386
displayName: java
Lines changed: 219 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,219 @@
1+
---
2+
title: "Tutorial: Integrate Admin for Spring with Eureka Server for Spring in Azure Container Apps"
3+
description: Learn to integrate Admin for Spring with Eureka Server for Spring in Azure Container Apps.
4+
services: container-apps
5+
author: craigshoemaker
6+
ms.service: container-apps
7+
ms.custom: devx-track-extended-java
8+
ms.topic: conceptual
9+
ms.date: 07/15/2024
10+
ms.author: cshoe
11+
---
12+
13+
# Tutorial: Integrate Admin for Spring with Eureka Server for Spring in Azure Container Apps
14+
15+
This tutorial will guide you through the process of integrating a managed Admin for Spring with a Eureka Server for Spring within Azure Container Apps.
16+
17+
This article contains some content similar to the "Connect to a managed Admin for Spring in Azure Container Apps" tutorial, but with Eureka Server for Spring, you can bind Admin for Spring to Eureka Server for Spring, so that it can get application information through Eureka, instead of having to bind individual applications to Admin for Spring.
18+
19+
By following this guide, you'll set up a Eureka Server for service discovery and then create an Admin for Spring to manage and monitor your Spring applications registered with the Eureka Server. This setup ensures that other applications only need to bind to the Eureka Server, simplifying the management of your microservices.
20+
21+
In this tutorial, you will learn to:
22+
23+
1. Create a Eureka Server for Spring.
24+
2. Create an Admin for Spring and link it to the Eureka Server.
25+
3. Bind other applications to the Eureka Server for streamlined service discovery and management.
26+
27+
## Prerequisites
28+
29+
To complete this tutorial, you need the following items:
30+
31+
| Requirement | Instructions |
32+
|--|--|
33+
| Azure account | An active subscription is required. If you don't have one, you [can create one for free](https://azure.microsoft.com/free/). |
34+
| Azure CLI | Install the [Azure CLI](/cli/azure/install-azure-cli).|
35+
| An existing Eureka Server for Spring Java component | If you don't have one, follow the [Create the Eureka Server for Spring](java-eureka-server.md#create-the-eureka-server-for-spring-java-component) section to create one. |
36+
37+
## Considerations
38+
39+
When running managed Java components in Azure Container Apps, be aware of the following details:
40+
41+
[!INCLUDE [container-apps/component-considerations.md](../../includes/container-apps/component-considerations.md)]
42+
43+
## Setup
44+
45+
Before you begin, create the necessary resources by executing the following commands.
46+
47+
1. Create variables to support your application configuration. These values are provided for you for the purposes of this lesson.
48+
49+
```bash
50+
export LOCATION=eastus
51+
export RESOURCE_GROUP=my-services-resource-group
52+
export ENVIRONMENT=my-environment
53+
export EUREKA_COMPONENT_NAME=eureka
54+
export ADMIN_COMPONENT_NAME=admin
55+
export CLIENT_APP_NAME=sample-service-eureka-client
56+
export CLIENT_IMAGE="mcr.microsoft.com/javacomponents/samples/sample-admin-for-spring-client:latest"
57+
```
58+
59+
| Variable | Description |
60+
|---|---|
61+
| `LOCATION` | The Azure region location where you create your container app and Java components. |
62+
| `RESOURCE_GROUP` | The Azure resource group name for your demo application. |
63+
| `ENVIRONMENT` | The Azure Container Apps environment name for your demo application. |
64+
| `EUREKA_COMPONENT_NAME` | The name of the Eureka Server Java component. |
65+
| `ADMIN_COMPONENT_NAME` | The name of the Admin for Spring Java component. |
66+
| `CLIENT_APP_NAME` | The name of the container app that will bind to the Eureka Server. |
67+
| `CLIENT_IMAGE` | The container image used in your Eureka Server container app. |
68+
69+
1. Log in to Azure with the Azure CLI.
70+
71+
```azurecli
72+
az login
73+
```
74+
75+
1. Create a resource group.
76+
77+
```azurecli
78+
az group create --name $RESOURCE_GROUP --location $LOCATION
79+
```
80+
81+
1. Create your container apps environment.
82+
83+
```azurecli
84+
az containerapp env create \
85+
--name $ENVIRONMENT \
86+
--resource-group $RESOURCE_GROUP \
87+
--location $LOCATION \
88+
--query "properties.provisioningState"
89+
```
90+
91+
Using the `--query` parameter filters the response down to a simple success or failure message.
92+
93+
## Optional: Create the Eureka Server for Spring
94+
95+
If you don't have an existing Eureka Server for Spring, follow the command below to create the Eureka Server Java component. For more information, see [Create the Eureka Server for Spring](java-eureka-server.md#create-the-eureka server-for-spring-java-component).
96+
97+
```azurecli
98+
az containerapp env java-component eureka-server-for-spring create \
99+
--environment $ENVIRONMENT \
100+
--resource-group $RESOURCE_GROUP \
101+
--name $EUREKA_COMPONENT_NAME
102+
```
103+
104+
## Bind the components together
105+
106+
Create the Admin for Spring Java component.
107+
108+
```azurecli
109+
az containerapp env java-component admin-for-spring create \
110+
--environment $ENVIRONMENT \
111+
--resource-group $RESOURCE_GROUP \
112+
--name $ADMIN_COMPONENT_NAME \
113+
--bind $EUREKA_COMPONENT_NAME
114+
```
115+
116+
## Bind other apps to the Eureka Server
117+
118+
With the Eureka Server set up, you can now bind other applications to it for service discovery. And you can also monitor and manage these applications in the dashboard of Admin for Spring. Follow the steps below to create and bind a container app to the Eureka Server:
119+
120+
Create the container app and bind it to the Eureka Server.
121+
122+
```azurecli
123+
az containerapp create \
124+
--name $CLIENT_APP_NAME \
125+
--resource-group $RESOURCE_GROUP \
126+
--environment $ENVIRONMENT \
127+
--image $CLIENT_IMAGE \
128+
--min-replicas 1 \
129+
--max-replicas 1 \
130+
--ingress external \
131+
--target-port 8080 \
132+
--bind $EUREKA_COMPONENT_NAME
133+
```
134+
135+
> [!TIP]
136+
> Since the previous steps bound the Admin for Spring component to the Eureka Server for Spring component, the Admin component enables service discovery and allows you to manage it through the Admin for Spring dashboard at the same time.
137+
138+
## View the dashboards
139+
140+
> [!IMPORTANT]
141+
> To view the dashboard, you need to have at least the `Microsoft.App/managedEnvironments/write` role assigned to your account on the managed environment resource. You can either explicitly assign `Owner` or `Contributor` role on the resource or follow the steps to create a custom role definition and assign it to your account.
142+
143+
1. Create the custom role definition.
144+
145+
```azurecli
146+
az role definition create --role-definition '{
147+
"Name": "Java Component Dashboard Access",
148+
"IsCustom": true,
149+
"Description": "Can access managed Java Component dashboards in managed environments",
150+
"Actions": [
151+
"Microsoft.App/managedEnvironments/write"
152+
],
153+
"AssignableScopes": ["/subscriptions/<SUBSCRIPTION_ID>"]
154+
}'
155+
```
156+
157+
Make sure to replace placeholder in between the `<>` brackets in the `AssignableScopes` value with your subscription ID.
158+
159+
1. Assign the custom role to your account on managed environment resource.
160+
161+
Get the resource id of the managed environment.
162+
163+
```azurecli
164+
export ENVIRONMENT_ID=$(az containerapp env show \
165+
--name $ENVIRONMENT --resource-group $RESOURCE_GROUP \
166+
--query id -o tsv)
167+
```
168+
169+
1. Assign the role to your account.
170+
171+
Before running this command, replace the placeholder in between the `<>` brackets with your user or service principal ID.
172+
173+
```azurecli
174+
az role assignment create \
175+
--assignee <USER_OR_SERVICE_PRINCIPAL_ID> \
176+
--role "Java Component Dashboard Access" \
177+
--scope $ENVIRONMENT_ID
178+
```
179+
180+
1. Get the URL of the Admin for Spring dashboard.
181+
182+
```azurecli
183+
az containerapp env java-component admin-for-spring show \
184+
--environment $ENVIRONMENT \
185+
--resource-group $RESOURCE_GROUP \
186+
--name $ADMIN_COMPONENT_NAME \
187+
--query properties.ingress.fqdn -o tsv
188+
```
189+
190+
1. Get the URL of the Eureka Server for Spring dashboard.
191+
192+
```azurecli
193+
az containerapp env java-component eureka-server-for-spring show \
194+
--environment $ENVIRONMENT \
195+
--resource-group $RESOURCE_GROUP \
196+
--name $EUREKA_COMPONENT_NAME \
197+
--query properties.ingress.fqdn -o tsv
198+
```
199+
200+
This command returns the URL you can use to access the Eureka Server for Spring dashboard. Through the dashboard, your container app is also to you as shown in the following screenshot.
201+
202+
:::image type="content" source="media/java-components/spring-boot-admin.png" alt-text="Screenshot of the Admin for Spring dashboard." lightbox="media/java-components/spring-boot-admin.png":::
203+
204+
:::image type="content" source="media/java-components/eureka.png" alt-text="Screenshot of the Eureka Server for Spring dashboard." lightbox="media/java-components/eureka.png":::
205+
206+
## Clean up resources
207+
208+
The resources created in this tutorial have an effect on your Azure bill. If you aren't going to use these services long-term, run the following command to remove everything created in this tutorial.
209+
210+
```azurecli
211+
az group delete \
212+
--resource-group $RESOURCE_GROUP
213+
```
214+
215+
## Next steps
216+
217+
> [!div class="nextstepaction"]
218+
> [Configure Eureka Server for Spring settings](java-eureka-server-usage.md)
219+
> [Configure Admin for Spring settings](java-admin-for-spring-usage.md)

0 commit comments

Comments
 (0)