{"id":3412,"library":"azure-loganalytics","title":"Azure Log Analytics Client Library (Deprecated)","description":"This is an older Microsoft Azure client library for interacting with Azure Log Analytics. It is no longer maintained and has been officially deprecated. For querying data, users are advised to migrate to the `azure-monitor-query` library. For ingesting data into Log Analytics, the `azure-monitor-ingestion` library should be used. The last stable release for this package was 0.1.1 in 2021.","status":"deprecated","version":"0.1.1","language":"en","source_language":"en","source_url":"https://github.com/Azure/azure-sdk-for-python","tags":["Azure","Log Analytics","Monitoring","Deprecated","Cloud"],"install":[{"cmd":"pip install azure-loganalytics","lang":"bash","label":"Deprecated Package"},{"cmd":"pip install azure-monitor-query azure-monitor-ingestion azure-identity","lang":"bash","label":"Recommended Replacement Packages"}],"dependencies":[{"reason":"Required for authentication with Azure Monitor Query and Ingestion client libraries.","package":"azure-identity","optional":false},{"reason":"Recommended replacement for querying Log Analytics data.","package":"azure-monitor-query","optional":false},{"reason":"Recommended replacement for ingesting data into Log Analytics.","package":"azure-monitor-ingestion","optional":false}],"imports":[{"note":"The original `azure-loganalytics` package is deprecated. Use `LogsQueryClient` from `azure-monitor-query` for current data querying.","wrong":"from azure.loganalytics import LogAnalyticsClient","symbol":"LogsQueryClient","correct":"from azure.monitor.query import LogsQueryClient"},{"note":"This is the standard authentication method for modern Azure SDKs.","symbol":"DefaultAzureCredential","correct":"from azure.identity import DefaultAzureCredential"}],"quickstart":{"code":"import os\nfrom azure.identity import DefaultAzureCredential\nfrom azure.monitor.query import LogsQueryClient\nfrom datetime import timedelta\n\n# Set your Log Analytics Workspace ID\n# Can be found in the Azure portal under your Log Analytics workspace's 'Overview' page\nLOGS_WORKSPACE_ID = os.environ.get(\"LOGS_WORKSPACE_ID\", \"<your_log_analytics_workspace_id>\")\n\n# Authenticate using DefaultAzureCredential\n# Ensure environment variables AZURE_CLIENT_ID, AZURE_TENANT_ID, AZURE_CLIENT_SECRET are set,\n# or you are logged in via 'az login' (Azure CLI) for this to work automatically.\ncredential = DefaultAzureCredential()\n\n# Create a LogsQueryClient\nclient = LogsQueryClient(credential)\n\n# Define a Kusto Query Language (KQL) query\nquery = \"\"\"\nAzureActivity\n| summarize count() by ResourceGroup\n| limit 5\n\"\"\"\n\ntry:\n    # Execute the query for data from the last 1 day\n    response = client.query_workspace(\n        LOGS_WORKSPACE_ID,\n        query,\n        timespan=timedelta(days=1)\n    )\n\n    # Process and print the results\n    if response.tables:\n        for table in response.tables:\n            print(f\"\\nTable: {table.name}\")\n            print(f\"Columns: {[col.name for col in table.columns]}\")\n            for row in table.rows:\n                print(row)\n    else:\n        print(\"No results found for the query.\")\nexcept Exception as e:\n    print(f\"An error occurred: {e}\")","lang":"python","description":"This quickstart demonstrates how to query Azure Log Analytics using the recommended `azure-monitor-query` client library. It authenticates using `DefaultAzureCredential` (which leverages environment variables or Azure CLI login) and executes a Kusto Query Language (KQL) query against a specified Log Analytics workspace. Replace `<your_log_analytics_workspace_id>` with your actual workspace ID."},"warnings":[{"fix":"Migrate your code to use `azure-monitor-query` for querying logs and `azure-monitor-ingestion` for sending custom logs. Install them via `pip install azure-monitor-query azure-monitor-ingestion azure-identity`.","message":"The `azure-loganalytics` package (0.1.1) is no longer maintained and has been deprecated. It will not receive new features or bug fixes. Continued use is not recommended for production environments.","severity":"breaking","affected_versions":"0.1.0, 0.1.1"},{"fix":"Refactor your application to use `LogsQueryClient` from `azure.monitor.query` and `LogsIngestionClient` from `azure.monitor.ingestion`. Refer to their respective documentation for migration guidance.","message":"The functionality for querying Azure Log Analytics programmatically has been moved to the `azure-monitor-query` library, and for ingesting data to `azure-monitor-ingestion`. These new libraries offer improved features, async support, and consistent Azure SDK patterns.","severity":"deprecated","affected_versions":"0.1.0, 0.1.1"},{"fix":"Ensure you are using the correct library for your task: `azure-mgmt-loganalytics` for management tasks, and `azure-monitor-query` for querying logs.","message":"There are multiple Azure Python packages related to Log Analytics. `azure-loganalytics` (this package) is for data operations and is deprecated. `azure-mgmt-loganalytics` is for *managing* Log Analytics workspaces (e.g., creating, updating, deleting workspaces). The modern data querying library is `azure-monitor-query`.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Install `azure-identity` and use `DefaultAzureCredential`. Set environment variables like `AZURE_CLIENT_ID`, `AZURE_TENANT_ID`, `AZURE_CLIENT_SECRET` or use `az login` via Azure CLI to enable automatic authentication.","message":"Authentication for modern Azure SDK client libraries relies on `azure-identity`. Older `azure-loganalytics` (if still used) might have different, outdated authentication patterns. `DefaultAzureCredential` is the recommended way to authenticate for new libraries.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}