Skip to content

Commit e5b7182

Browse files
More edits.
1 parent f49c1ec commit e5b7182

File tree

1 file changed

+127
-123
lines changed

1 file changed

+127
-123
lines changed

articles/container-apps/java-application-performance-management-config.md

Lines changed: 127 additions & 123 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ author: karler
1313

1414
# Tutorial: Configure Application Performance Management (APM) Java agent with init-container in Azure Container Apps
1515

16-
Apply Java agent and init containers in Azure Container Apps to inject Application Performance Management (APM) solutions without modifying your app image. While you can package the APM plugin in the same image or Dockerfile with your app, this binds together management efforts like release and Common Vulnerabilities and Exposures (CVE) mitigation.
16+
This article shows you how to configure Application Performance Management (APM) Java agent with init containers in Azure Container Apps, which injects APM solutions without modifying your app image. While you can package the APM plugin in the same image or Dockerfile with your app, doing that binds together management efforts like release and Common Vulnerabilities and Exposures (CVE) mitigation.
1717

1818
In this tutorial, you learn how to:
1919

@@ -80,15 +80,15 @@ The following steps define environment variables and ensure your Container Apps
8080
# [Bash](#tab/bash)
8181

8282
```bash
83-
az extension add -n containerapp --upgrade
84-
az extension add -n application-insights --upgrade
83+
az extension add --name containerapp --upgrade
84+
az extension add --name application-insights --upgrade
8585
```
8686

8787
# [PowerShell](#tab/powershell)
8888

8989
```powershell
90-
az extension add -n containerapp --upgrade
91-
az extension add -n application-insights --upgrade
90+
az extension add --name containerapp --upgrade
91+
az extension add --name application-insights --upgrade
9292
```
9393

9494
1. To retrieve the connection string of Application Insights, use the following commands:
@@ -111,7 +111,7 @@ The following steps define environment variables and ensure your Container Apps
111111

112112
## Prepare the container image
113113

114-
To build a setup image for Application Insights Java agent, perform these following steps in the same directory:
114+
To build a setup image for Application Insights Java agent, perform the following steps in the same directory:
115115

116116
1. Save the following Dockerfile:
117117

@@ -157,7 +157,7 @@ To build a setup image for Application Insights Java agent, perform these follow
157157
docker build . -t "$CONTAINER_REGISTRY_NAME.azurecr.io/samples/java-agent-setup:1.0.0"
158158
```
159159

160-
1. Push the image to Azure Container Registry or another container image registry by using the following command:
160+
1. Push the image to Azure Container Registry or another container image registry by using the following commands:
161161

162162
# [Bash](#tab/bash)
163163

@@ -174,190 +174,194 @@ To build a setup image for Application Insights Java agent, perform these follow
174174
```
175175

176176
> [!TIP]
177-
> You can find code relevant to this step in the [Azure Contaier Apps Java Samples](https://github.com/Azure-Samples/azure-container-apps-java-samples) GitHub repo.
177+
> You can find code relevant to this step in the [azure-container-apps-java-samples](https://github.com/Azure-Samples/azure-container-apps-java-samples) GitHub repo.
178178

179179
## Create a Container Apps environment and a Container App as the target Java app
180180

181-
1. Create a Container Apps environment.
181+
To create a Container Apps environment and a container app as the target Java app, perform the following steps:
182+
183+
1. Create a Container Apps environment by using the following command:
182184

183185
# [Bash](#tab/bash)
184186

185187
```bash
186188
az containerapp env create \
187-
--name $ENVIRONMENT_NAME \
188-
--resource-group $RESOURCE_GROUP \
189-
--location "$LOCATION" \
190-
--query "properties.provisioningState"
189+
--name $ENVIRONMENT_NAME \
190+
--resource-group $RESOURCE_GROUP \
191+
--location "$LOCATION" \
192+
--query "properties.provisioningState"
191193
```
192194

193195
# [PowerShell](#tab/powershell)
194196

195197
```powershell
196198
az containerapp env create `
197-
--name $ENVIRONMENT_NAME `
198-
--resource-group $RESOURCE_GROUP `
199-
--location "$LOCATION" `
200-
--query "properties.provisioningState"
199+
--name $ENVIRONMENT_NAME `
200+
--resource-group $RESOURCE_GROUP `
201+
--location "$LOCATION" `
202+
--query "properties.provisioningState"
201203
```
202204

203-
Once created, the command returns a "Succeeded" message.
205+
After successfully creating the Container Apps environment, the command line returns a `Succeeded` message.
204206

205-
1. Create a Container app for further configurations.
207+
1. Create a Container app for further configurations by using the following command:
206208

207209
# [Bash](#tab/bash)
208210

209211
```bash
210212
az containerapp create \
211-
--name $CONTAINER_APP_NAME \
212-
--environment $ENVIRONMENT_NAME \
213-
--resource-group $RESOURCE_GROUP \
214-
--query "properties.provisioningState"
213+
--name $CONTAINER_APP_NAME \
214+
--environment $ENVIRONMENT_NAME \
215+
--resource-group $RESOURCE_GROUP \
216+
--query "properties.provisioningState"
215217
```
216218

217219
# [PowerShell](#tab/powershell)
218220

219221
```powershell
220222
az containerapp create `
221-
--name $CONTAINER_APP_NAME `
222-
--environment $ENVIRONMENT_NAME `
223-
--resource-group $RESOURCE_GROUP `
224-
--query "properties.provisioningState"
223+
--name $CONTAINER_APP_NAME `
224+
--environment $ENVIRONMENT_NAME `
225+
--resource-group $RESOURCE_GROUP `
226+
--query "properties.provisioningState"
225227
```
226228

227-
Once created, the command returns a "Succeeded" message.
229+
After successfully creating the Container App, the command line returns a `Succeeded` message.
230+
231+
## Configure init container, secrets, environment variables, and volumes to set up Application Insights integration
228232

229-
## Configure init-container, secrets, environment variables, and volumes to set up Application Insights integration
233+
To configure your init container with secrets, environment variables, and volumes so it can be used with Insights, perform the following steps:
230234

231-
1. Get current configurations of the running Container App.
235+
1. Write the current configurations of the running Container App to **app.yml** in the current directory, by using the following command:
232236

233237
# [Bash](#tab/bash)
234238

235239
```bash
236240
az containerapp show \
237-
--name $CONTAINER_APP_NAME \
238-
--resource-group $RESOURCE_GROUP \
239-
-o yaml > app.yaml
241+
--resource-group $RESOURCE_GROUP \
242+
--name $CONTAINER_APP_NAME \
243+
--output yaml \
244+
> app.yaml
240245
```
241246

242247
# [PowerShell](#tab/powershell)
243248

244249
```powershell
245250
az containerapp show `
246-
--name $CONTAINER_APP_NAME `
247-
--resource-group $RESOURCE_GROUP `
248-
-o yaml > app.yaml
251+
--resource-group $RESOURCE_GROUP `
252+
--name $CONTAINER_APP_NAME `
253+
--output yaml `
254+
> app.yaml
249255
```
250256

251-
The YAML file `app.yaml` is created in current directory.
257+
1. Edit the configurations in **app.yml** by using the following instructions:
252258

253-
1. Edit the app YAML file.
259+
1. Add a secret for Application Insights connection string using the following code snippet:
254260

255-
- Add secret for Application Insights connection string
256-
257-
```yaml
258-
properties:
259-
configuration:
260-
secrets:
261-
- name: app-insights-connection-string
262-
value: $CONNECTION_STRING
263-
```
261+
```yaml
262+
properties:
263+
configuration:
264+
secrets:
265+
- name: app-insights-connection-string
266+
value: $CONNECTION_STRING
267+
```
264268

265-
Replace $CONNECTION_STRING with your Azure Application Insights connection string.
269+
Replace $CONNECTION_STRING with your Azure Application Insights connection string.
266270

267-
- Add ephemeral storage volume for Java agent files
271+
1. Add ephemeral storage volume for Java agent files using the following code snippet:
268272

269-
```yaml
270-
properties:
271-
template:
272-
volumes:
273-
- name: java-agent-volume
274-
storageType: EmptyDir
275-
```
276-
277-
- Add init-container with volume mounts and environment variables
273+
```yaml
274+
properties:
275+
template:
276+
volumes:
277+
- name: java-agent-volume
278+
storageType: EmptyDir
279+
```
280+
281+
1. Add an init container with volume mounts and environment variables, using the following code snippet:
278282

279-
```yaml
280-
properties:
281-
template:
282-
initContainers:
283-
- image: <CONTAINER_REGISTRY_NAME>.azurecr.io/samples/java-agent-setup:1.0.0
284-
name: java-agent-setup
285-
resources:
286-
cpu: 0.25
287-
memory: 0.5Gi
288-
env:
289-
- name: CONNECTION_STRING
290-
secretRef: app-insights-connection-string
291-
volumeMounts:
292-
- mountPath: /java-agent
293-
volumeName: java-agent-volume
294-
```
295-
296-
Replace `<CONTAINER_REGISTRY_NAME>` with your Azure Container Registry name.
297-
298-
- Update app container with volume mounts and environment variables
283+
```yaml
284+
properties:
285+
template:
286+
initContainers:
287+
- image: <CONTAINER_REGISTRY_NAME>.azurecr.io/samples/java-agent-setup:1.0.0
288+
name: java-agent-setup
289+
resources:
290+
cpu: 0.25
291+
memory: 0.5Gi
292+
env:
293+
- name: CONNECTION_STRING
294+
secretRef: app-insights-connection-string
295+
volumeMounts:
296+
- mountPath: /java-agent
297+
volumeName: java-agent-volume
298+
```
299+
300+
Replace `<CONTAINER_REGISTRY_NAME>` with your Azure Container Registry name.
301+
302+
1. Update the app container with volume mounts and environment variables, using the following code snippets:
299303

300-
```yaml
301-
properties:
302-
template:
303-
containers:
304-
- name: test-java-app
305-
image: mcr.microsoft.com/azurespringapps/samples/hello-world:0.0.1
306-
resources:
307-
cpu: 0.5
308-
memory: 1Gi
309-
env:
310-
- name: JAVA_TOOL_OPTIONS
311-
value: -javaagent:/java-agent/agent.jar
312-
volumeMounts:
313-
- mountPath: /java-agent
314-
volumeName: java-agent-volume
315-
```
316-
317-
1. Update the container app with modified YAML file.
318-
319-
# [Bash](#tab/bash)
320-
321-
```bash
322-
az containerapp update \
323-
--name $CONTAINER_APP_NAME \
324-
--resource-group $RESOURCE_GROUP \
325-
--yaml app.yaml \
326-
--query "properties.provisioningState"
327-
```
328-
329-
# [PowerShell](#tab/powershell)
330-
331-
```powershell
332-
az containerapp update `
333-
--name $CONTAINER_APP_NAME `
334-
--resource-group $RESOURCE_GROUP `
335-
--yaml app.yaml `
336-
--query "properties.provisioningState"
337-
```
338-
339-
Once updated, the command returns a "Succeeded" message. Then you can check out your Application Insights in Azure portal to see your Container App is connected.
340-
304+
```yaml
305+
properties:
306+
template:
307+
containers:
308+
- name: test-java-app
309+
image: mcr.microsoft.com/azurespringapps/samples/hello-world:0.0.1
310+
resources:
311+
cpu: 0.5
312+
memory: 1Gi
313+
env:
314+
- name: JAVA_TOOL_OPTIONS
315+
value: -javaagent:/java-agent/agent.jar
316+
volumeMounts:
317+
- mountPath: /java-agent
318+
volumeName: java-agent-volume
319+
```
320+
321+
1. Update the container app with the modified YAML file, using the following command:
322+
323+
# [Bash](#tab/bash)
324+
325+
```bash
326+
az containerapp update \
327+
--name $CONTAINER_APP_NAME \
328+
--resource-group $RESOURCE_GROUP \
329+
--yaml app.yaml \
330+
--query "properties.provisioningState"
331+
```
332+
333+
# [PowerShell](#tab/powershell)
334+
335+
```powershell
336+
az containerapp update `
337+
--name $CONTAINER_APP_NAME `
338+
--resource-group $RESOURCE_GROUP `
339+
--yaml app.yaml `
340+
--query "properties.provisioningState"
341+
```
342+
343+
After updating the container app, the command returns a `Succeeded` message. Then you can view your Application Insights in the Azure portal to verify that your container app is connected.
344+
341345
## Clean up resources
342346

343-
The resources created in this tutorial contribute to your Azure bill. If you aren't going to keep them in the long term, run the following commands to clean them up.
347+
The resource group you created in this tutorial contributes to your Azure bill. If you aren't going to need it in the long term, use the following command to remove it:
344348
345349
# [Bash](#tab/bash)
350+
346351
```bash
347352
az group delete --resource-group $RESOURCE_GROUP
348353
```
354+
349355
# [PowerShell](#tab/powershell)
350356
```powershell
351357
az group delete --resource-group $RESOURCE_GROUP
352358
```
353359
354-
---
355-
356360
## Other APM solutions
357361
358362
Other than [Azure Application Insights](/azure/azure-monitor/app/java-standalone-config), there are other popular APM solutions in the community. If you want to integrate your Azure Container App with other APM providers, just replace the Java agent JAR and related config files.
359363
360364
- [AppDynamics](https://docs.appdynamics.com/appd/21.x/21.4/en/application-monitoring/install-app-server-agents/java-agent/install-the-java-agent)
361365
- [Dynatrace](https://docs.dynatrace.com/docs/setup-and-configuration/technology-support/application-software/java)
362366
- [Elastic](https://www.elastic.co/guide/en/apm/agent/java/index.html)
363-
- [NewRelic](https://docs.newrelic.com/docs/apm/agents/java-agent/getting-started/introduction-new-relic-java/)
367+
- [New Relic](https://docs.newrelic.com/docs/apm/agents/java-agent/getting-started/introduction-new-relic-java/)

0 commit comments

Comments
 (0)