From 1a91bde24341c79d5eef54b08fef2f16904bad3e Mon Sep 17 00:00:00 2001 From: "learn-build-service-prod[bot]" <113403604+learn-build-service-prod[bot]@users.noreply.github.com> Date: Wed, 22 Jul 2026 00:30:47 +0800 Subject: [PATCH] Confirm merge from repo_sync_working_branch to main to sync with https://github.com/MicrosoftDocs/dataexplorer-docs (branch main) (#7548) * Clarify Parquet continuous export performance for wide tables (#2900) * Clarify Parquet continuous export performance for wide tables * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Silas Mendes Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * Implement resource ID retrieval for Azure authentication (#2918) * Implement resource ID retrieval for Azure authentication Added code to fetch resource ID from metadata for Azure Data Explorer authentication. * Update authenticate-with-msal.md * Refactor resource ID retrieval to C# Updated the method for fetching resource ID from Kusto service metadata, switching from Java to C# code. * Clarify MSAL authentication support for ingest endpoint Updated the code sample to clarify that the MSAL authentication flow is supported for the 'ingest-' endpoint. --------- Co-authored-by: learn-build-service-prod[bot] <113403604+learn-build-service-prod[bot]@users.noreply.github.com> Co-authored-by: Silas Mendes <61285023+silasmendes-ms@users.noreply.github.com> Co-authored-by: Silas Mendes Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Co-authored-by: Learn Build Service GitHub App Co-authored-by: ohad bitton <32278684+ohadbitt@users.noreply.github.com> --- .../kusto/api/rest/authenticate-with-msal.md | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/data-explorer/kusto/api/rest/authenticate-with-msal.md b/data-explorer/kusto/api/rest/authenticate-with-msal.md index 78b7598d05..b7767e60db 100644 --- a/data-explorer/kusto/api/rest/authenticate-with-msal.md +++ b/data-explorer/kusto/api/rest/authenticate-with-msal.md @@ -72,7 +72,7 @@ request.Headers.Set(HttpRequestHeader.Authorization, string.Format(CultureInfo.I ## Perform application authentication with MSAL -The following code sample shows how to use MSAL to get an authorization token for your cluster. In this flow, no prompt is presented. The application must be registered with Microsoft Entra ID and have an app key or an X509v2 certificate issued by Microsoft Entra ID. To set up an application, see [Provision a Microsoft Entra application](../../access-control/provision-entra-id-app.md). +The following code sample shows how to use MSAL to get an authorization token for your cluster. In this flow, no prompt is presented. The application must be registered with Microsoft Entra ID and have an app key or an X509v2 certificate issued by Microsoft Entra ID. To set up an application, see [Provision a Microsoft Entra application](../../access-control/provision-entra-id-app.md). This is supported for the "ingest-" endpoint as well. ```csharp var kustoUri = "https://..kusto.windows.net"; @@ -82,8 +82,23 @@ var authClient = ConfidentialClientApplicationBuilder.Create("") .WithClientSecret("") // Can be replaced by .WithCertificate to authenticate with an X.509 certificate .Build(); + + string resourceId = null; + + try + { + // Get the appropiate resource id by querying the metadata + var httpClient = new HttpClient(); + var response = httpClient.GetByteArrayAsync($"{kustoUri}/v1/rest/auth/metadata").Result; + var json = JObject.Parse(Encoding.UTF8.GetString(response)); + resourceId = json["AzureAD"]?["KustoServiceResourceId"]?.ToString(); +} +catch { + resourceId = "https://kusto.kusto.windows.net"; +} + var result = authClient.AcquireTokenForClient( - new[] { $"{kustoUri}/.default" } // Define scopes for accessing Azure Data Explorer cluster + new[] { $"{resourceId}/.default" } // Define scopes for accessing Azure Data Explorer cluster ).ExecuteAsync().Result; var bearerToken = result.AccessToken;