Skip to content

Commit 1a91bde

Browse files
learn-build-service-prod[bot]silasmendes-mssilasmendesCopilotLearn Build Service GitHub App
authored
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 <silasmendes@gmail.com> 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 <silasmendes@gmail.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Co-authored-by: Learn Build Service GitHub App <Learn Build Service LearnBuild@microsoft.com> Co-authored-by: ohad bitton <32278684+ohadbitt@users.noreply.github.com>
1 parent 295416d commit 1a91bde

1 file changed

Lines changed: 17 additions & 2 deletions

File tree

‎data-explorer/kusto/api/rest/authenticate-with-msal.md‎

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ request.Headers.Set(HttpRequestHeader.Authorization, string.Format(CultureInfo.I
7272
7373
## Perform application authentication with MSAL
7474

75-
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).
75+
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.
7676

7777
```csharp
7878
var kustoUri = "https://<clusterName>.<region>.kusto.windows.net";
@@ -82,8 +82,23 @@ var authClient = ConfidentialClientApplicationBuilder.Create("<appId>")
8282
.WithClientSecret("<appKey>") // Can be replaced by .WithCertificate to authenticate with an X.509 certificate
8383
.Build();
8484

85+
86+
string resourceId = null;
87+
88+
try
89+
{
90+
// Get the appropiate resource id by querying the metadata
91+
var httpClient = new HttpClient();
92+
var response = httpClient.GetByteArrayAsync($"{kustoUri}/v1/rest/auth/metadata").Result;
93+
var json = JObject.Parse(Encoding.UTF8.GetString(response));
94+
resourceId = json["AzureAD"]?["KustoServiceResourceId"]?.ToString();
95+
}
96+
catch {
97+
resourceId = "https://kusto.kusto.windows.net";
98+
}
99+
85100
var result = authClient.AcquireTokenForClient(
86-
new[] { $"{kustoUri}/.default" } // Define scopes for accessing Azure Data Explorer cluster
101+
new[] { $"{resourceId}/.default" } // Define scopes for accessing Azure Data Explorer cluster
87102
).ExecuteAsync().Result;
88103
var bearerToken = result.AccessToken;
89104

0 commit comments

Comments
 (0)