Registry / azure / azure-mgmt-loganalytics

azure-mgmt-loganalytics

JSON →
library13.1.1pypypiunverified

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.

azuretype-stubs
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
musl
py 3.103.930 runs
installs and imports cleanly · install 0.0s · import 0.651s · 44.9MB
glibc
py 3.103.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}'.")
Debug
Known footguns
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.
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.
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.
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.
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.
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.

Agent activity
15 hits · last 30 days
gptbot
4
ahrefsbot
4
bytedance
3
amazonbot
1
claudebot
1
Resources