Forum Discussion
Zicozen
7 months agoNew Member
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 ...
- 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" """
tayloramy
Super User
7 months agoHi Zicozen,
Are you running the notebook manually, or is it being run as the service principal throughb a pipeline?
If you're running the notebook manually, notebookutils will be using your account as the security context, so you will need to make sure that your account has access to the log analytics workspace.