{"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":"python","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)"},{"fix":"Ensure 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`).","message":"Azure 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.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure 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)`).","message":"Azure 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.","severity":"breaking","affected_versions":"All versions for management libraries"}],"env_vars":null,"search_vec":"'13.1.1':65 'adher':51 'allow':24 'analyt':3,17,30,92 'api':55 'authent':59 'azur':1,8,15,40,46,67,85,88 'azure-mgmt-loganalyt':7 'bi':79 'bi-month':78 'cadenc':74 'client':5,19 'cloud':89 'current':58,62 'develop':25 'follow':70 'frequent':72 'general':69 'guidelin':56 'keep':82 'librari':11,20 'link':33 'log':2,16,29,91 'loganalyt':10 'manag':4,18,28,90 'mgmt':9 'microsoft':14 'monitor':93 'month':76,80 'often':75 'pace':83 'part':42 'pattern':60 'programmat':27 'python':22,49 'relat':37 'releas':73 'resourc':38 'sdk':47,94 'sdks':68 'servic':34,86 'solut':32 'unifi':54 'updat':87 'version':63 'wider':45 'within':39 'workspac':31","created_at":"2026-04-09T03:44:58.673942+00:00","updated_at":"2026-04-15T22:49:48.738434+00:00","problems":{"verify_error":"error: Failed to parse: `azure-mgmt-loganalytics azure-identity`\n  Caused by: Expected one of `@`, `(`, `<`, `=`, `>`, `~`, `!`, `;`, found `a`\nazure-mgmt-loganalytics azure-identity\n                        ^"},"ecosystem":"pypi","meta_description":null,"install_score":100,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"14.0.0","cli_name":"","cli_version":null,"type":"library","homepage":"https://docs.microsoft.com/python/api/overview/azure/mgmt-loganalytics","github":"https://github.com/Azure/azure-sdk-for-python","docs":null,"changelog":null,"pypi":"https://pypi.org/project/azure-mgmt-loganalytics/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["azure","type-stubs"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-08-27","next_check":"2026-07-05","install_tag":"verified"}}