Forum Discussion

Zicozen's avatar
Zicozen
New Member
7 months ago
Solved

Connecting to Azure Log Analytics for my Fabric Notebook

I am trying to read the data from Azure Log Analytics from a Fabric Notebook The fabric workspace identity is created and service principal that gets created in Entra Id has been given Log Reader ...
  • deborshi_nag's avatar
    7 months ago

    Hi Zicozen 

     

    You can't use Workspace Identity to authenticate to Azure Log Analytics - already covered in another thread. 

    Fabric workspace identities cannot currently acquire tokens for the Azure Monitor (Log Analytics) resource provider.

     

    Solved: Re: Unable to Use Managed Identity Authentication ... - Microsoft Fabric Community

     

     You can however use a service principal (Azure AD App Registration) and use the code below -

     

    from azure.identity import ClientSecretCredential
    from azure.monitor.query import LogsQueryClient
    from datetime import timedelta
    import pandas as pd
    
    tenant_id = "<TENANT-ID>"
    client_id = "<CLIENT-ID>"
    client_secret = "<CLIENT-SECRET>"
    
    credential = ClientSecretCredential(
        tenant_id=tenant_id,
        client_id=client_id,
        client_secret=client_secret
    )
    
    client = LogsQueryClient(credential)
    
    kql_query = """
    SigninLogs
    | where TimeGenerated >= ago(7d)
    | where AppDisplayName == "Windows Sign In"
    """