My code to read from the Log Analytics Workspace
fails with the titular error.
from azure.identity import DefaultAzureCredential
from azure.loganalytics import LogAnalyticsDataClient
from azure.loganalytics.models import QueryBody
from IPython.core.debugger import set_trace
# Replace these variables with your actual values
workspace_id = 'ABCDE'
query = """ddex_CL
| take 100
"""
credential = DefaultAzureCredential()
client = LogAnalyticsDataClient(credential)
query_body = QueryBody(query=query)
body=query_body)
response = client.query(workspace_id, body=query_body).execute()
for row in response.tables[0].rows:
print(row)
Note: there are similar question here: Exception: AttributeError: 'DefaultAzureCredential' object has no attribute 'signed_session' using Azure Function and Python . The most upvoted answer says
As of May 2022, all SDKs have been re-released with native support for azure-identity
But I still encounter the error even though installing the latest version via:
pip3 install azure-loganalytics azure-identity
pip show azure-loganalytics
Name: azure-loganalytics
Version: 0.1.1
$pip show azure-identity
Name: azure-identity
Version: 1.14.0
Another similar question is here: AttributeError: 'DefaultAzureCredential' object has no attribute 'signed_session' . But I do already have the lastest library version installed.
Are there any other library or code changes that are needed?
azure-loganalytics is no longer maintained (see https://pypi.org/project/azure-loganalytics/), and has been replaced by https://pypi.org/project/azure-monitor-query. This package will support azure-identity.
For more questions, do not hesitate to go on the Github repo of the SDK: https://github.com/Azure/azure-sdk-for-python/issues
(I'm the manager of the Azure Python SDK team at Microsoft)