Registry /
azure / azure-mgmt-loganalytics
The `azure-mgmt-loganalytics` library is the Microsoft Azure Log Analytics Management Client Library for Python. It allows developers to programmatically manage Log Analytics workspaces, solutions, linked services, and other related resources within Azure. As part of the wider Azure SDK for Python, it adheres to the unified API guidelines and current authentication patterns. The current version is 13.1.1, and Azure SDKs generally follow a frequent release cadence, often monthly or bi-monthly, to keep pace with Azure service updates.
Install & Compatibility
Where this runs
tested against v13.1.1 · 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.930 runs
installs and imports cleanly · install 0.0s · import 0.651s · 44.9MB
glibcpy 3.10–3.930 runs
installs and imports cleanly · install 3.8s · import 0.587s · 45MB
44MB installed
● package 44MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
from azure.mgmt.loganalytics import LogAnalyticsManagementClient
Old authentication methods like `ServicePrincipalCredentials` or `MSIAuthentication` are deprecated in favor of `azure-identity`'s `DefaultAzureCredential` or specific credential types.
from azure.identity import DefaultAzureCredential
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}'.")
Upgrade
Version history
Breaking-change detection hasn't run for this library yet.
Audit
Security & dependencies
CVE tracking and dependency tree are planned for a later release.