Skip to content

Commit 8653305

Browse files
authored
Merge pull request #283815 from Descatles/wenhao/jc-portal
Add java component portal
2 parents 43a15cb + 3ca4ef6 commit 8653305

File tree

2 files changed

+312
-47
lines changed

2 files changed

+312
-47
lines changed

articles/container-apps/java-config-server.md

Lines changed: 161 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ author: craigshoemaker
66
ms.service: azure-container-apps
77
ms.custom: devx-track-azurecli, devx-track-extended-java
88
ms.topic: tutorial
9-
ms.date: 03/13/2024
9+
ms.date: 08/13/2024
1010
ms.author: cshoe
1111
---
1212

1313
# Tutorial: Connect to a managed Config Server for Spring in Azure Container Apps (preview)
1414

1515
Config Server for Spring provides a centralized location to make configuration data available to multiple applications. In this article, you learn to connect an app hosted in Azure Container Apps to a Java Config Server for Spring instance.
1616

17-
The Config Server for Spring component uses a GitHub repository as the source for configuration settings. Configuration values are made available to your container app via a binding between the component and your container app. As values change in the configuration server, they automatically flow to your application, all without requiring you to recompile or redeploy your application.
17+
The Config Server for Spring Java component uses a GitHub repository as the source for configuration settings. Configuration values are made available to your container app via a binding between the component and your container app. As values change in the configuration server, they automatically flow to your application, all without requiring you to recompile or redeploy your application.
1818

1919
In this tutorial, you learn to:
2020

@@ -45,22 +45,24 @@ When running in Config Server for Spring in Azure Container Apps, be aware of th
4545
| **Scope** | The Config Server for Spring runs in the same environment as the connected container app. |
4646
| **Scaling** | To maintain a single source of truth, the Config Server for Spring doesn't scale. The scaling properties `minReplicas` and `maxReplicas` are both set to `1`. |
4747
| **Resources** | The container resource allocation for Config Server for Spring is fixed, the number of the CPU cores is 0.5, and the memory size is 1Gi. |
48-
| **Pricing** | The Config Server for Spring billing falls under consumption-based pricing. Resources consumed by managed Java components are billed at the active/idle rates. You may delete components that are no longer in use to stop billing. |
48+
| **Pricing** | The Config Server for Spring billing falls under consumption-based pricing. Resources consumed by managed Java components are billed at the active/idle rates. You can delete components that are no longer in use to stop billing. |
4949
| **Binding** | The container app connects to a Config Server for Spring via a binding. The binding injects configurations into container app environment variables. Once a binding is established, the container app can read configuration values from environment variables. |
5050

5151
## Setup
5252

5353
Before you begin to work with the Config Server for Spring, you first need to create the required resources.
5454

55+
### [Azure CLI](#tab/azure-cli)
56+
5557
Execute the following commands to create your resource group and Container Apps environment.
5658

5759
1. Create variables to support your application configuration. These values are provided for you for the purposes of this lesson.
5860

5961
```bash
6062
export LOCATION=eastus
61-
export RESOURCE_GROUP=my-spring-cloud-resource-group
62-
export ENVIRONMENT=my-spring-cloud-environment
63-
export JAVA_COMPONENT_NAME=myconfigserver
63+
export RESOURCE_GROUP=my-services-resource-group
64+
export ENVIRONMENT=my-environment
65+
export JAVA_COMPONENT_NAME=configserver
6466
export APP_NAME=my-config-client
6567
export IMAGE="mcr.microsoft.com/javacomponents/samples/sample-service-config-client:latest"
6668
export URI="https://github.com/Azure-Samples/azure-spring-cloud-config-java-aca.git"
@@ -75,7 +77,7 @@ Execute the following commands to create your resource group and Container Apps
7577
| `IMAGE` | The container image used in your container app. |
7678
| `URI` | You can replace the URI with your git repo url, if it's private, add the related authentication configurations such as `spring.cloud.config.server.git.username` and `spring.cloud.config.server.git.password`. |
7779
78-
1. Log in to Azure with the Azure CLI.
80+
1. Sign in to Azure with the Azure CLI.
7981
8082
```azurecli
8183
az login
@@ -96,11 +98,66 @@ Execute the following commands to create your resource group and Container Apps
9698
--location $LOCATION
9799
```
98100
99-
This environment is used to host both the Config Server for Spring component and your container app.
101+
### [Azure portal](#tab/azure-portal)
102+
103+
Use the following steps to create each of the resources necessary to create a container app.
104+
105+
1. Search for **Container Apps** in the Azure portal and select **Create**.
106+
107+
1. Enter the following values to *Basics* tab.
108+
109+
| Property | Value |
110+
|---|---|
111+
| **Subscription** | Select your Azure subscription. |
112+
| **Resource group** | Select **Create new** link to create a new resource group named **my-resource-group**. |
113+
| **Container app name** | Enter **my-config-client**. |
114+
| **Deployment source** | Select **Container image**. |
115+
| **Region** | Select the region nearest you. |
116+
| **Container Apps environment** | Select the **Create new** link to create a new environment. |
117+
118+
1. In the *Create Container Apps environment* window, enter the following values.
119+
120+
| Property | Value |
121+
|---|---|
122+
| **Environment name** | Enter **my-environment**. |
123+
| **Zone redundancy** | Select **Disabled**. |
124+
125+
Select the **Create** button, and then select the **Container** tab.
126+
127+
1. In *Container* tab, enter the following values.
128+
129+
| Property | Value |
130+
|---|---|
131+
| **Name** | Enter **my-config-client**. |
132+
| **Image source** | Select **Docker Hub or other registries**. |
133+
| **Image type** | Select **Public**. |
134+
| **Registry login server** | Enter **mcr.microsoft.com**. |
135+
| **Image and tag** | Enter **javacomponents/samples/sample-service-config-client:latest**. |
136+
137+
Select the **Ingress** tab.
138+
139+
1. In *Ingress* tab, enter the following and leave the rest of the form with their default values.
140+
141+
| Property | Value |
142+
|---|---|
143+
| **Ingress** | Select **Enabled**. |
144+
| **Ingress traffic** | Select **Accept traffic from anywhere**. |
145+
| **Ingress type** | Select **HTTP**. |
146+
| **Target port** | Enter **8080**. |
147+
148+
Select **Review + create**.
149+
150+
1. Once the validation checks pass, select **Create** to create your container app.
151+
152+
---
153+
154+
This environment is used to host both the Config Server for Spring java component and your container app.
100155
101-
## Use the Config Server for Spring Java component
156+
## Create the Config Server for Spring Java component
102157
103-
Now that you have a Container Apps environment, you can create your container app and bind it to a Config Server for Spring component. When you bind your container app, configuration values automatically synchronize from the Config Server component to your application.
158+
Now that you have a Container Apps environment, you can create your container app and bind it to a Config Server for Spring java component. When you bind your container app, configuration values automatically synchronize from the Config Server component to your application.
159+
160+
### [Azure CLI](#tab/azure-cli)
104161
105162
1. Create the Config Server for Spring Java component.
106163
@@ -124,6 +181,42 @@ Now that you have a Container Apps environment, you can create your container ap
124181
125182
Here, you're telling the component where to find the repository that holds your configuration information via the `uri` property. The `refresh-rate` property tells Container Apps how often to check for changes in your git repository.
126183

184+
### [Azure portal](#tab/azure-portal)
185+
186+
Now that you have an existing environment and config server client container app, you can create a Java component instance of Config Server for Spring.
187+
188+
1. Go to your container app's environment in the portal.
189+
190+
1. From the left menu, under *Services* category, select **Services**.
191+
192+
1. Select **+ Configure** drop down, and select **Java component**.
193+
194+
1. In the *Configure Java component* panel, enter the following values.
195+
196+
| Property | Value |
197+
|---|---|
198+
| **Java component type** | Select **Config Server for Spring**. |
199+
| **Java component name** | Enter **configserver**. |
200+
201+
1. In the *Git repositories* section, select the **+ Add** button and enter the following values.
202+
203+
| Property | Value |
204+
|---|---|
205+
| **Type** | Select **HTTP**. |
206+
| **URI** | Enter **https://github.com/Azure-Samples/azure-spring-cloud-config-java-aca.git**. |
207+
208+
Leave the rest of the fields with the default values and select **Add**.
209+
210+
1. Select **Next**.
211+
212+
1. On the *Review* tab, select **Configure**.
213+
214+
---
215+
216+
## Bind your container app to the Config Server for Spring Java component
217+
218+
### [Azure CLI](#tab/azure-cli)
219+
127220
1. Create the container app that consumes configuration data.
128221
129222
```azurecli
@@ -143,7 +236,7 @@ Now that you have a Container Apps environment, you can create your container ap
143236
144237
If you visit your app in a browser, the `connectTimeout` value returned is the default value of `0`.
145238
146-
1. Bind to the Config Server for Spring.
239+
2. Bind to the Config Server for Spring.
147240
148241
Now that the container app and Config Server are created, you bind them together with the `update` command to your container app.
149242
@@ -156,36 +249,73 @@ Now that you have a Container Apps environment, you can create your container ap
156249
157250
The `--bind $JAVA_COMPONENT_NAME` parameter creates the link between your container app and the configuration component.
158251
159-
Once the container app and the Config Server component are bound together, configuration changes are automatically synchronized to the container app.
252+
### [Azure portal](#tab/azure-portal)
160253
161-
When you visit the app's URL again, the value of `connectTimeout` is now `10000`. This value comes from the git repo set in the `$URI` variable originally set as the source of the configuration component. Specifically, this value is drawn from the `connectionTimeout` property in the repo's *application.yml* file.
254+
1. Go to your container app environment in the portal.
162255
163-
The bind request injects configuration setting into the application as environment variables. These values are now available to the application code to use when fetching configuration settings from the config server.
256+
1. From the left menu, under *Services* category, select **Services**.
164257
165-
In this case, the following environment variables are available to the application:
258+
1. From the list, select **configserver**.
166259
167-
```bash
168-
SPRING_CLOUD_CONFIG_URI=http://$JAVA_COMPONENT_NAME:80
169-
SPRING_CLOUD_CONFIG_COMPONENT_URI=http://$JAVA_COMPONENT_NAME:80
170-
SPRING_CONFIG_IMPORT=optional:configserver:$SPRING_CLOUD_CONFIG_URI
171-
```
260+
1. Under *bindings, select the *App name* drop-down and select **my-config-client**.
172261
173-
If you want to customize your own `SPRING_CONFIG_IMPORT`, you can refer to the environment variable `SPRING_CLOUD_CONFIG_COMPONENT_URI`, for example, you can override by command line arguments, like `Java -Dspring.config.import=optional:configserver:${SPRING_CLOUD_CONFIG_COMPONENT_URI}?fail-fast=true`.
262+
1. Select the **Review** tab.
174263
175-
You can also remove a binding from your application.
264+
1. Select the **Configure** button.
176265
177-
1. Unbind the Config Server for Spring Java component.
266+
1. Return to your container app in the portal and copy the URL of your app to a text editor so you can use it in a coming step.
178267
179-
To remove a binding from a container app, use the `--unbind` option.
268+
---
180269
181-
``` azurecli
182-
az containerapp update \
183-
--name $APP_NAME \
184-
--unbind $JAVA_COMPONENT_NAME \
185-
--resource-group $RESOURCE_GROUP
186-
```
270+
Once the container app and the Config Server component are bound together, configuration changes are automatically synchronized to the container app.
271+
272+
When you visit the app's URL again, the value of `connectTimeout` is now `10000`. This value comes from the git repo set in the `$URI` variable originally set as the source of the configuration component. Specifically, this value is drawn from the `connectionTimeout` property in the repo's *application.yml* file.
273+
274+
The bind request injects configuration setting into the application as environment variables. These values are now available to the application code to use when fetching configuration settings from the config server.
275+
276+
In this case, the following environment variables are available to the application:
277+
278+
```bash
279+
SPRING_CLOUD_CONFIG_URI=http://[JAVA_COMPONENT_INTERNAL_FQDN]:80
280+
SPRING_CLOUD_CONFIG_COMPONENT_URI=http://[JAVA_COMPONENT_INTERNAL_FQDN]:80
281+
SPRING_CONFIG_IMPORT=optional:configserver:$SPRING_CLOUD_CONFIG_URI
282+
```
283+
284+
If you want to customize your own `SPRING_CONFIG_IMPORT`, you can refer to the environment variable `SPRING_CLOUD_CONFIG_COMPONENT_URI`, for example, you can override by command line arguments, like `Java -Dspring.config.import=optional:configserver:${SPRING_CLOUD_CONFIG_COMPONENT_URI}?fail-fast=true`.
285+
286+
You can also remove a binding from your application.
287+
288+
## Unbind your container app from the Config Server for Spring Java component
289+
290+
### [Azure CLI](#tab/azure-cli)
291+
To remove a binding from a container app, use the `--unbind` option.
292+
293+
``` azurecli
294+
az containerapp update \
295+
--name $APP_NAME \
296+
--unbind $JAVA_COMPONENT_NAME \
297+
--resource-group $RESOURCE_GROUP
298+
```
299+
300+
### [Azure portal](#tab/azure-portal)
301+
302+
1. Go to your container app environment in the portal.
303+
304+
1. From the left menu, under *Services* category, select **Services**.
187305
188-
When you visit the app's URL again, the value of `connectTimeout` changes to back to `0`.
306+
1. From the list, select **configserver**.
307+
308+
1. Under *Bindings*, find the line for *my-config-client* select and select **Delete**.
309+
310+
1. Select **Next**.
311+
312+
1. Select the **Review** tab.
313+
314+
1. Select the **Configure** button.
315+
316+
---
317+
318+
When you visit the app's URL again, the value of `connectTimeout` changes to back to `0`.
189319

190320
## Clean up resources
191321

@@ -200,4 +330,3 @@ az group delete \
200330
201331
> [!div class="nextstepaction"]
202332
> [Customize Config Server for Spring settings](java-config-server-usage.md)
203-

0 commit comments

Comments
 (0)