如何使用应用程序密钥身份验证对ADXProxy进行身份验证?

问题描述 投票:0回答:1

我正在尝试使用(预览)ADXProxy功能通过Redash访问Azure Application Insights资源。

[我已经在Azure中创建了一个应用注册,并且我有一些概念验证的python代码,可以成功访问我的Application Insights资源并使用应用程序令牌执行Kusto查询(traces | take 1):

import azure.kusto
import azure.kusto.data.request
import msal

cluster = 'https://ade.applicationinsights.io/subscriptions/<MY_SUBSCRIPTION>/resourcegroups/<MY_RESOURCE_GROUP>/providers/microsoft.insights/components/<MY_APP_INSIGHTS_RESOURCE>'
app_id = '<MY_APP_ID>'
app_key = '<MY_SECRET>'
authority_id = '<MY_AAD_SUBSCRIPTION_ID>'

def run():

    app = msal.ConfidentialClientApplication(
        client_id=app_id, 
        client_credential=app_key, 
        authority='https://login.microsoftonline.com/<MY_AAD_SUBSCRIPTION_ID>')

    token = app.acquire_token_for_client(['https://help.kusto.windows.net/.default'])

    kcsb = azure.kusto.data.request.KustoConnectionStringBuilder.with_aad_application_token_authentication(
        connection_string=cluster,
        application_token=token['access_token']
    )

    client = azure.kusto.data.request.KustoClient(kcsb)

    result = client.execute('<MY_APP_INSIGHTS_RESOURCE>', 'traces | take 1')

    for res in result.primary_results:
        print(res)

    return 1

if __name__ == "__main__":
    run()

但是,Redash不支持应用程序令牌认证:它使用应用程序密钥认证,像这样进行呼叫:

    kcsb = azure.kusto.data.request.KustoConnectionStringBuilder.with_aad_application_key_authentication(
        connection_string = cluster,
        aad_app_id = app_id,
        app_key = app_key,
        authority_id = '<MY_AAD_SUBSCRIPTION_ID>'
    )

我无法使用这种类型的流程成功连接到我的App Insights资源。如果我将此KustoConnectionStringBuilder替换为上面的程序,则会收到异常消息:

在名为的租户中找不到名为https://ade.applicationinsights.io的资源主体。如果租户的管理员未安装该应用程序,或者该租户中的任何用户未同意该应用程序,则可能发生这种情况。您可能已将身份验证请求发送给错误的租户。

我可以在代码或Azure门户配置中做一些事情来将我的'租户'连接到ade.applicationinsights.io资源主体并让此连接正常工作吗?

msal kusto azure-data-explorer redash adxproxy
1个回答
0
投票

[Adxproxy仅支持Azure Active Directory(AAD)铸造的令牌。必须为您拥有的Azure数据资源管理器群集(ADX)创建令牌。如果您没有自己的ADX群集,并且出于任何原因想要通过Adxproxy访问Application Insights资源,则始终可以验证为“ https://help.kusto.windows.net”并使用该令牌。

© www.soinside.com 2019 - 2024. All rights reserved.