{"id":1369,"library":"azure-mgmt-loganalytics","title":"Azure Log Analytics Management Client","description":"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.","status":"active","version":"13.1.1","language":"en","source_language":"en","source_url":"https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/loganalytics/azure-mgmt-loganalytics","tags":["azure","cloud","management","log analytics","monitor","sdk"],"install":[{"cmd":"pip install azure-mgmt-loganalytics azure-identity","lang":"bash","label":"Install core library and authentication"}],"dependencies":[],"imports":[{"symbol":"LogAnalyticsManagementClient","correct":"from azure.mgmt.loganalytics import LogAnalyticsManagementClient"},{"note":"Old authentication methods like `ServicePrincipalCredentials` or `MSIAuthentication` are deprecated in favor of `azure-identity`'s `DefaultAzureCredential` or specific credential types.","wrong":"from msrestazure.azure_exceptions import CloudError","symbol":"DefaultAzureCredential","correct":"from azure.identity import DefaultAzureCredential"}],"quickstart":{"code":"import os\nfrom azure.identity import DefaultAzureCredential\nfrom azure.mgmt.loganalytics import LogAnalyticsManagementClient\n\n# Ensure you have AZURE_SUBSCRIPTION_ID and other Azure credentials set in your environment\n# E.g., AZURE_CLIENT_ID, AZURE_CLIENT_SECRET, AZURE_TENANT_ID for service principal\n# Or login via `az login` for DefaultAzureCredential to pick up user credentials\n\nsubscription_id = os.environ.get(\"AZURE_SUBSCRIPTION_ID\", \"YOUR_SUBSCRIPTION_ID\")\nresource_group_name = os.environ.get(\"AZURE_RESOURCE_GROUP\", \"my-loganalytics-rg\")\n\nif not subscription_id or subscription_id == \"YOUR_SUBSCRIPTION_ID\":\n    raise ValueError(\"Please set the AZURE_SUBSCRIPTION_ID environment variable.\")\n\ncredential = DefaultAzureCredential()\nclient = LogAnalyticsManagementClient(credential, subscription_id)\n\nprint(f\"Listing Log Analytics workspaces in subscription {subscription_id}...\")\n\n# Example: List all workspaces in a specific resource group\n# For simplicity, this example just lists the first 5 if available\nworkspaces = client.workspaces.list_by_resource_group(resource_group_name)\n\nfound_any = False\nfor i, workspace in enumerate(workspaces):\n    if i >= 5: # Limit output for quickstart\n        break\n    print(f\"- Workspace: {workspace.name} (Location: {workspace.location})\")\n    found_any = True\n\nif not found_any:\n    print(f\"No Log Analytics workspaces found in resource group '{resource_group_name}'.\")\n","lang":"python","description":"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."},"warnings":[{"fix":"Migrate 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`.","message":"Authentication 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.","severity":"breaking","affected_versions":">=12.0.0"},{"fix":"For 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`.","message":"This 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.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Always 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.","message":"When 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.","severity":"gotcha","affected_versions":"Major version upgrades (e.g., 12.x.x to 13.x.x)"}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}