> ## 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.

# Python을 Insights에 연결

> Azure Kusto Python SDK와 Microsoft Entra ID 인증을 사용하여 Python 및 Jupyter Notebooks에서 게임 데이터에 대한 레거시 PlayFab Insights를 쿼리합니다.

# 자습서: Python을 Insights에 연결

이 가이드는 Python을 Insights와 함께 사용하여 시작하는 방법을 안내합니다. Azure Kusto Python SDK를 사용합니다. 연결한 후에는 Python으로 게임 데이터를 쿼리하고 Jupyter Notebooks에서 라이브러리를 사용할 수 있습니다. 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>

## 필수 구성 요소

### Azure AD로 인증된 PlayFab 계정

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

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

* PlayFab [로그인 페이지](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)

## Python 패키지 설치

1. [pip](https://pypi.org/project/pip/)를 사용하여 다음 Python 패키지를 설치합니다.
   * azure-kusto-data
   * azure-kusto-ingest
   * adal
2. 다음은 시작할 때 사용할 수 있는 예제 스크립트입니다.

```python theme={null}
from azure.kusto.data.exceptions import KustoServiceError
from azure.kusto.data.request import KustoClient, KustoConnectionStringBuilder, ClientRequestProperties

from msal import ConfidentialClientApplication

cluster = "https://insights.playfab.com"

# These parameters are taken from your Azure app
client_id = "<Azure app client id>"
client_secret = "<Azure app client secret>" 
tenant = "<Azure app tenant id>"

authority_url = "https://login.microsoftonline.com/" + tenant

client_instance = ConfidentialClientApplication(
  client_id=client_id,
  client_credential=client_secret,
  authority=authority_url,
)

# Acquire a token from AAD to pass to PlayFab
_scopes = ["https://help.kusto.windows.net"]
token_response = client_instance.acquire_token_for_client(scopes=_scopes)

token = None
if token_response:
    if token_response['access_token']:
        token = token_response['access_token']

kcsb = KustoConnectionStringBuilder.with_aad_application_token_authentication(cluster, token)
client = KustoClient(kcsb)

db = "<title id>"
query = "['events.all'] | count"

# Force Kusto to use the v1 query endpoint
client._query_endpoint = cluster + "/v1/rest/query"

crp = ClientRequestProperties()
crp.application = "KustoPythonSDK"
response = client.execute(db, query)

# Response processing
print(response)
```

## 추가 리소스

* [Azure Kusto Python SDK documentation](https://learn.microsoft.com/en-us/azure/data-explorer/kusto/api/python/kusto-python-client-library)
* Insights에 연결할 다른 도구에 대해 알아보려면 [외부 도구를 Insights에 연결](/services/playfab/data-analytics/legacy/connectivity)을 참조하세요.


## Related topics

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