Registry /
azure / azure-mgmt-loganalytics
Install & Compatibility
Where this runs
tested against v14.0.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.638s · 45.3MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 3.9s · import 0.590s · 46MB
45MB installed
● package 45MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
LogAnalyticsManagementClient
✓ from azure.mgmt.loganalytics import LogAnalyticsManagementClient
DefaultAzureCredential
✓ from azure.identity import DefaultAzureCredential
✗ from msrestazure.azure_exceptions import CloudError
Old authentication methods like `ServicePrincipalCredentials` or `MSIAuthentication` are deprecated in favor of `azure-identity`'s `DefaultAzureCredential` or specific credential types.
This quickstart demonstrates how to authenticate using `DefaultAzureCredential` and create a `LogAnalyticsManagementClient`. It then lists Log Analytics workspaces within a specified resource group. Ensure `AZURE_SUBSCRIPTION_ID` and `AZURE_RESOURCE_GROUP` (or substitute for an existing RG) are set as environment variables, or other Azure credentials are configured for `DefaultAzureCredential` to pick up.
import os
from azure.identity import DefaultAzureCredential
from azure.mgmt.loganalytics import LogAnalyticsManagementClient
# Ensure you have AZURE_SUBSCRIPTION_ID and other Azure credentials set in your environment
# E.g., AZURE_CLIENT_ID, AZURE_CLIENT_SECRET, AZURE_TENANT_ID for service principal
# Or login via `az login` for DefaultAzureCredential to pick up user credentials
subscription_id = os.environ.get("AZURE_SUBSCRIPTION_ID", "YOUR_SUBSCRIPTION_ID")
resource_group_name = os.environ.get("AZURE_RESOURCE_GROUP", "my-loganalytics-rg")
if not subscription_id or subscription_id == "YOUR_SUBSCRIPTION_ID":
raise ValueError("Please set the AZURE_SUBSCRIPTION_ID environment variable.")
credential = DefaultAzureCredential()
client = LogAnalyticsManagementClient(credential, subscription_id)
print(f"Listing Log Analytics workspaces in subscription {subscription_id}...")
# Example: List all workspaces in a specific resource group
# For simplicity, this example just lists the first 5 if available
workspaces = client.workspaces.list_by_resource_group(resource_group_name)
found_any = False
for i, workspace in enumerate(workspaces):
if i >= 5: # Limit output for quickstart
break
print(f"- Workspace: {workspace.name} (Location: {workspace.location})")
found_any = True
if not found_any:
print(f"No Log Analytics workspaces found in resource group '{resource_group_name}'.")
Debug
Known issues
breakingAuthentication with `msrestazure` based credentials (e.g., `ServicePrincipalCredentials`, `MSIAuthentication`) is deprecated or removed in recent major versions (v12+). The modern and recommended approach is to use `azure-identity`'s `DefaultAzureCredential` or other specific credential classes.fixMigrate your authentication code to use `azure.identity.DefaultAzureCredential`. This credential supports multiple authentication flows (environment variables, managed identity, Azure CLI, etc.) without code changes. Install it with `pip install azure-identity`.
affects: >=12.0.0
gotchaThis library (`azure-mgmt-loganalytics`) is for *managing* Log Analytics workspaces (creating, updating, deleting workspaces, managing linked services, etc.). It is NOT for *querying* data within a workspace or performing data plane operations.fixFor querying log data from Log Analytics workspaces, use the `azure-monitor-query` library. For managing diagnostic settings and other monitoring-related configurations, consider `azure-mgmt-monitor`.
affects: All versions
gotchaWhen upgrading between major versions of `azure-mgmt-loganalytics` (e.g., from v12 to v13), there might be breaking changes in API surface areas, such as parameter names, method signatures, or model object structures. This is due to updates in the underlying Azure REST API.fixAlways consult the official Azure SDK for Python release notes and migration guides when upgrading major versions. Test your code thoroughly after an upgrade. Pay close attention to `CloudError` messages for clues on API contract changes.
affects: Major version upgrades (e.g., 12.x.x to 13.x.x)
gotchaAzure management libraries, including `azure-mgmt-loganalytics`, typically require the `AZURE_SUBSCRIPTION_ID` environment variable to be set for authenticating and targeting the correct Azure subscription. Without it, operations that require a subscription context will fail.fixEnsure the `AZURE_SUBSCRIPTION_ID` environment variable is set in your environment. You can obtain your subscription ID from the Azure portal or via the Azure CLI (`az account show --query id -o tsv`). For local development, also consider authenticating with `DefaultAzureCredential` by logging in via Azure CLI (`az login`).
affects: All versions
breakingAzure management libraries (like `azure-mgmt-loganalytics`) require an Azure subscription ID to identify the target subscription for management operations. The client typically attempts to retrieve this from the `AZURE_SUBSCRIPTION_ID` environment variable, or it must be explicitly passed during client instantiation.fixEnsure the `AZURE_SUBSCRIPTION_ID` environment variable is set in your execution environment, or explicitly pass the subscription ID when creating the management client (e.g., `LogAnalyticsManagementClient(credential, subscription_id)`).
affects: All versions for management libraries
Upgrade
Version history
14.0.0latest on PyPI · released Jun 24, 2026
Audit
Dependencies
No dependency data recorded yet.