> ## Documentation Index
> Fetch the complete documentation index at: https://devdocs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Kusto C# SDK를 Insights에 연결

> Microsoft Entra ID 인증과 함께 Kusto C# SDK를 사용하여 Azure Functions 또는 사용자 지정 .NET 애플리케이션에서 레거시 PlayFab Insights 게임 데이터를 쿼리합니다.

# 자습서: Kusto C# SDK를 Insights에 연결

이 가이드는 Kusto C# SDK를 Insights와 함께 사용하여 시작하는 방법을 안내합니다. 연결한 후에는 Azure Functions에서 Insights를 쿼리할 수 있습니다. Insights와 연결할 수 있는 다른 도구에 대해 자세히 알아보려면 [외부 도구를 Insights에 연결](/services/playfab/data-analytics/legacy/connectivity)을 참조하세요.

<Note>
  PlayFab Insights Management는 2026년 3월 31일에 사용이 중단되었습니다. 앞으로 성능과 비용을 관리하려면 [Azure Data Explorer(ADX) Connections](/services/playfab/data-analytics/export-data/data-connection-adx)를 사용하는 것을 권장합니다. 타이틀이 아직 **Insights**를 사용하고 있다면 구현 세부 정보는 이 문서를 계속 참고하세요. 자세한 내용은 [PlayFab Digest: March feature updates](https://developer.microsoft.com/en-us/games/articles/2026/04/playfab-digest-march-feature-updates/)를 참조하세요.
</Note>

## 필수 구성 요소

### AAD로 인증된 PlayFab 계정

인증 공급자가 Microsoft로 설정된 PlayFab 계정 또는 사용자가 필요합니다. Microsoft 인증 공급자는 Azure Active Directory(AAD)를 사용하여 인증을 수행하며, 이는 Azure 서비스를 사용하기 위해 필수적입니다. AAD로 인증된 계정 또는 사용자를 만드는 방법은 [Game Manager용 Azure Active Directory 인증](/services/playfab/identity/dev-identity/authentication/aad-authentication)을 참조하세요.

계정 또는 사용자가 Microsoft 인증 공급자를 사용하도록 설정되어 있는지 확인하려면:

* [developer.playfab.com](https://developer.playfab.com)을 방문하세요.
* **Sign in with Microsoft**를 선택하여 PlayFab 계정에 액세스하세요.

로그인할 수 있다면 해당 계정은 Microsoft 인증 공급자를 사용하도록 설정되어 있는 것입니다.

### Insights용 Game Manager 권한

계정에 다음 Game Manager 권한이 활성화된 [사용자 역할](/services/playfab/identity/dev-identity/permissions/playfab-user-roles)을 할당해야 합니다.

* 관리자 상태.
* Explorer 탭 및 관련 데이터에 대한 액세스.
* Analytics 데이터에 대한 읽기 및 쓰기 액세스.

새 사용자 역할을 만들거나 기존 역할에 이러한 권한을 추가할 수 있습니다.

### 기타 필수 구성 요소

* [Azure Active Directory(AAD) 애플리케이션을 만들고 타이틀 데이터베이스에 연결](/services/playfab/data-analytics/legacy/connectivity/creating-AAD-app-for-insights)

## 패키지 설치

1. 다음 NuGet 패키지를 설치합니다.
   * 필수: [Microsoft.Azure.Kusto.Data](https://www.nuget.org/packages/Microsoft.Azure.Kusto.Data/)
   * 선택: [Microsoft.Azure.Kusto.Ingest](https://www.nuget.org/packages/Microsoft.Azure.Kusto.Ingest/)
   * 추가 선택 패키지는 [Kusto .NET SDK documentation](https://learn.microsoft.com/en-us/azure/data-explorer/kusto/api/netfx/about-the-sdk)을 참조하세요.
2. 다음은 시작할 때 사용할 수 있는 샘플 코드입니다.

```csharp theme={null}
namespace HelloPlayFabInsights
{
    using System;
    using Kusto.Data;
    using Kusto.Data.Common;
    using Kusto.Data.Net.Client;

    class Program
    {
        const string Cluster = "https://insights.playfab.com";
        const string Database = "<title id>";
        const string AzureAuthority = "microsoft.onmicrosoft.com";
        const string ClientId = "<app id>";
        const string ClientSecret = "<app secret>";

        static void Main()
        {
            var kcsb = new KustoConnectionStringBuilder(Cluster, Database).WithAadApplicationKeyAuthentication(ClientId, ClientSecret, AzureAuthority);

            Console.WriteLine("Run Query...");
            RunQuery(kcsb);

            Console.WriteLine("Run Command...");
            RunCommand(kcsb);
            
        }
    
        /// <summary>
        /// Run a query on your Insights database, and write the results to the console.
        /// </summary>
        /// <param name="kcsb"></param>
        static void RunQuery(KustoConnectionStringBuilder kcsb)
        {
            using (var queryProvider = KustoClientFactory.CreateCslQueryProvider(kcsb))
            {
                var query = "['events.all'] | limit 10";

                var clientRequestProperties = new ClientRequestProperties() {
                    Application = "DotNetSDK",
                    ClientRequestId = Guid.NewGuid().ToString() 
                };
                using (var reader = queryProvider.ExecuteQuery(query, clientRequestProperties))
                { 
                    while (reader.Read())
                    {
                        string name = reader.GetString(2);
                        string titleId = reader.GetString(5);
                        DateTime timestamp = reader.GetDateTime(8);
                        Console.WriteLine("{0}\t{1}\t{2}", name, titleId, timestamp);
                    }
                }
            }
        }

        /// <summary>
        /// Run the ".show tables" command on your Insights database, and write the results to the console.
        /// </summary>
        /// <param name="kcsb"></param>
        static void RunCommand(KustoConnectionStringBuilder kcsb)
        {
            using (var commandProvider = KustoClientFactory.CreateCslAdminProvider(kcsb))
            {
                var command = ".show tables";

                var clientRequestProperties = new ClientRequestProperties()
                {
                    Application = "DotNetSDK",
                    ClientRequestId = Guid.NewGuid().ToString()
                };
                using (var reader = commandProvider.ExecuteControlCommand(command, clientRequestProperties))
                {
                    while (reader.Read())
                    {
                        string tableName = reader.GetString(0);
                        string databaseName = reader.GetString(1);
                        Console.WriteLine("{0}\t{1}", tableName, databaseName);
                    }
                }
            }
        }
    }
}
```

## 추가 리소스

* [Azure Kusto .NET Samples](https://github.com/Azure/azure-kusto-samples-dotnet)
* [Kusto client library documentation](https://learn.microsoft.com/en-us/azure/data-explorer/kusto/api/netfx/about-kusto-data)


## Related topics

- [Kusto Explorer를 Insights에 연결](/ko/services/playfab/data-analytics/legacy/connectivity/connecting-kusto-explorer-to-insights.md)
- [Grafana를 Insights에 연결](/ko/services/playfab/data-analytics/legacy/connectivity/connecting-grafana-to-insights.md)
- [Azure Data Explorer를 Insights에 연결](/ko/services/playfab/data-analytics/legacy/connectivity/connecting-azure-data-explorer-to-insights.md)
- [Power BI를 Insights에 연결](/ko/services/playfab/data-analytics/legacy/connectivity/connecting-power-bi-to-insights.md)
- [Azure Data Factory(ADF)를 Insights에 연결](/ko/services/playfab/data-analytics/legacy/connectivity/connecting-azure-data-factory-to-insights.md)
