Skip to content

Commit 16cb1f9

Browse files
Merge pull request #253852 from AaronMaxwell/aaronmax-java-aadauth-envvar
Java APPLICATIONINSIGHTS_AUTHENTICATION_STRING env var info
2 parents b1f1f3f + 8a90d1a commit 16cb1f9

File tree

1 file changed

+41
-17
lines changed

1 file changed

+41
-17
lines changed

articles/azure-monitor/app/azure-ad-authentication.md

Lines changed: 41 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,6 @@ services.AddApplicationInsightsTelemetry(new ApplicationInsightsServiceOptions
100100
});
101101
```
102102

103-
[!INCLUDE [azure-monitor-log-analytics-rebrand](../../../includes/azure-monitor-instrumentation-key-deprecation.md)]
104-
105103
### [Node.js](#tab/nodejs)
106104

107105
> [!NOTE]
@@ -137,8 +135,6 @@ appInsights.defaultClient.config.aadTokenCredential = credential;
137135

138136
```
139137

140-
[!INCLUDE [azure-monitor-log-analytics-rebrand](../../../includes/azure-monitor-instrumentation-key-deprecation.md)]
141-
142138
### [Java](#tab/java)
143139

144140
> [!NOTE]
@@ -204,7 +200,37 @@ The following example shows how to configure the Java agent to use a service pri
204200

205201
:::image type="content" source="media/azure-ad-authentication/client-secret-cs.png" alt-text="Screenshot that shows the Client secrets section with the client secret." lightbox="media/azure-ad-authentication/client-secret-cs.png":::
206202

207-
[!INCLUDE [azure-monitor-log-analytics-rebrand](../../../includes/azure-monitor-instrumentation-key-deprecation.md)]
203+
#### Environment variable configuration
204+
205+
The `APPLICATIONINSIGHTS_AUTHENTICATION_STRING` environment variable lets Application Insights authenticate to Azure AD and send telemetry.
206+
207+
- For system-assigned identity:
208+
209+
| App setting | Value |
210+
| -------------- |--------- |
211+
| APPLICATIONINSIGHTS_AUTHENTICATION_STRING | `Authorization=AAD` |
212+
213+
- For user-assigned identity:
214+
215+
| App setting | Value |
216+
| ------------- | -------- |
217+
| APPLICATIONINSIGHTS_AUTHENTICATION_STRING | `Authorization=AAD;ClientId={Client id of the User-Assigned Identity}` |
218+
219+
Set the `APPLICATIONINSIGHTS_AUTHENTICATION_STRING` environment variable using this string.
220+
221+
**In Unix/Linux:**
222+
223+
```shell
224+
export APPLICATIONINSIGHTS_AUTHENTICATION_STRING="Authorization=AAD"
225+
```
226+
227+
**In Windows:**
228+
229+
```shell
230+
set APPLICATIONINSIGHTS_AUTHENTICATION_STRING="Authorization=AAD"
231+
```
232+
233+
After setting it, restart your application. It now sends telemetry to Application Insights using Azure AD authentication.
208234

209235
### [Python](#tab/python)
210236

@@ -214,7 +240,7 @@ is included starting with beta version [opencensus-ext-azure 1.1b0](https://pypi
214240

215241
Construct the appropriate [credentials](/python/api/overview/azure/identity-readme#credentials) and pass them into the constructor of the Azure Monitor exporter. Make sure your connection string is set up with the instrumentation key and ingestion endpoint of your resource.
216242

217-
The following types of authentication are supported by the `Opencensus` Azure Monitor exporters. We recommend using managed identities in production environments.
243+
The `OpenCensus`` Azure Monitor exporters support these authentication types. We recommend using managed identities in production environments.
218244

219245
#### System-assigned managed identity
220246

@@ -273,8 +299,6 @@ tracer = Tracer(
273299
...
274300
```
275301
---
276-
[!INCLUDE [azure-monitor-log-analytics-rebrand](../../../includes/azure-monitor-instrumentation-key-deprecation.md)]
277-
-
278302

279303
## Disable local authentication
280304

@@ -286,19 +310,19 @@ You can disable local authentication by using the Azure portal or Azure Policy o
286310

287311
1. From your Application Insights resource, select **Properties** under the **Configure** heading in the menu on the left. Select **Enabled (click to change)** if the local authentication is enabled.
288312

289-
:::image type="content" source="./media/azure-ad-authentication/enabled.png" alt-text="Screenshot that shows Properties under the Configure section and the Enabled (click to change) local authentication button.":::
313+
:::image type="content" source="./media/azure-ad-authentication/enabled.png" alt-text="Screenshot that shows Properties under the Configure section and the Enabled (select to change) local authentication button.":::
290314

291315
1. Select **Disabled** and apply changes.
292316

293317
:::image type="content" source="./media/azure-ad-authentication/disable.png" alt-text="Screenshot that shows local authentication with the Enabled/Disabled button.":::
294318

295319
1. After your resource has disabled local authentication, you'll see the corresponding information in the **Overview** pane.
296320

297-
:::image type="content" source="./media/azure-ad-authentication/overview.png" alt-text="Screenshot that shows the Overview tab with the Disabled (click to change) local authentication button.":::
321+
:::image type="content" source="./media/azure-ad-authentication/overview.png" alt-text="Screenshot that shows the Overview tab with the Disabled (select to change) local authentication button.":::
298322

299323
### Azure Policy
300324

301-
Azure Policy for `DisableLocalAuth` will deny users the ability to create a new Application Insights resource without this property set to `true`. The policy name is `Application Insights components should block non-AAD auth ingestion`.
325+
Azure Policy for `DisableLocalAuth` denies users the ability to create a new Application Insights resource without this property set to `true`. The policy name is `Application Insights components should block non-AAD auth ingestion`.
302326

303327
To apply this policy definition to your subscription, [create a new policy assignment and assign the policy](../../governance/policy/assign-policy-portal.md).
304328

@@ -408,7 +432,7 @@ The following example shows the Azure Resource Manager template you can use to c
408432

409433
### Token audience
410434

411-
When developing a custom client to obtain an access token from Azure AD for the purpose of submitting telemetry to Application Insights, refer to the table provided below to determine the appropriate audience string for your particular host environment.
435+
When developing a custom client to obtain an access token from Azure AD for submitting telemetry to Application Insights, refer to the following table to determine the appropriate audience string for your particular host environment.
412436

413437
| Azure cloud version | Token audience value |
414438
| --- | --- |
@@ -420,15 +444,15 @@ If you're using sovereign clouds, you can find the audience information in the c
420444

421445
_InstrumentationKey={profile.InstrumentationKey};IngestionEndpoint={ingestionEndpoint};LiveEndpoint={liveDiagnosticsEndpoint};AADAudience={aadAudience}_
422446

423-
Please note that the audience parameter, AADAudience, may vary depending on your specific environment.
447+
The audience parameter, AADAudience, may vary depending on your specific environment.
424448

425449
## Troubleshooting
426450

427451
This section provides distinct troubleshooting scenarios and steps that you can take to resolve an issue before you raise a support ticket.
428452

429453
### Ingestion HTTP errors
430454

431-
The ingestion service will return specific errors, regardless of the SDK language. Network traffic can be collected by using a tool such as Fiddler. You should filter traffic to the ingestion endpoint set in the connection string.
455+
The ingestion service returns specific errors, regardless of the SDK language. Network traffic can be collected by using a tool such as Fiddler. You should filter traffic to the ingestion endpoint set in the connection string.
432456

433457
#### HTTP/1.1 400 Authentication not supported
434458

@@ -486,7 +510,7 @@ You can inspect network traffic by using a tool like Fiddler. To enable the traf
486510

487511
Or add the following JVM args while running your application: `-Djava.net.useSystemProxies=true -Dhttps.proxyHost=localhost -Dhttps.proxyPort=8888`
488512

489-
If Azure AD is enabled in the agent, outbound traffic will include the HTTP header `Authorization`.
513+
If Azure AD is enabled in the agent, outbound traffic includes the HTTP header `Authorization`.
490514

491515
#### 401 Unauthorized
492516

@@ -505,7 +529,7 @@ If the following WARN message is seen in the log file `WARN c.m.a.TelemetryChann
505529
If you're using Fiddler, you might see the response header `HTTP/1.1 403 Forbidden - provided credentials do not grant the access to ingest the telemetry into the component`.
506530

507531
The root cause might be one of the following reasons:
508-
- You've created the resource with system-assigned managed identity enabled or you might have associated the user-assigned identity with the resource but forgot to add the Monitoring Metrics Publisher role to the resource (if using SAMI) or user-assigned identity (if using UAMI).
532+
- You've created the resource with a system-assigned managed identity or associated a user-assigned identity with it. However, you might have forgotten to add the Monitoring Metrics Publisher role to the resource (if using SAMI) or the user-assigned identity (if using UAMI).
509533
- You've provided the right credentials to get the access tokens, but the credentials don't belong to the right Application Insights resource. Make sure you see your resource (VM or app service) or user-assigned identity with Monitoring Metrics Publisher roles in your Application Insights resource.
510534

511535
#### Invalid Tenant ID
@@ -520,7 +544,7 @@ If the following exception is seen in the log file `com.microsoft.aad.msal4j.Msa
520544

521545
If the following exception is seen in the log file `com.microsoft.aad.msal4j.MsalServiceException: Application with identifier <CLIENT_ID> was not found in the directory`, it indicates the agent wasn't successful in acquiring the access token. The probable reason is that you've provided an invalid or the wrong client ID in your client secret configuration
522546

523-
This scenario can occur if the application hasn't been installed by the administrator of the tenant or consented to by any user in the tenant. You might have sent your authentication request to the wrong tenant.
547+
If the administrator hasn't installed the application or no user in the tenant has consented to it, this scenario occurs. You may have sent your authentication request to the wrong tenant.
524548

525549
### [Python](#tab/python)
526550

0 commit comments

Comments
 (0)