Azure Monitor Query for Python
Generate Python code for querying Azure Monitor logs and metrics.
The skill prefers DefaultAzureCredential, discourages connection strings and API keys, and requires deterministic cleanup for clients and async credentials. Its examples are read-oriented for logs and metrics, with no destructive defaults or credential theft. Points are deducted because least-privilege RBAC, sensitive-log handling, data-flow disclosure, user confirmation, isolation, rollback, and dependency security policy are not specified; versions are also unpinned.
The evidence covers sync, async, batch queries, partial-result handling, and lifecycle cleanup, so the main path is plausible. Points are deducted because static review cannot verify execution; examples omit necessary imports such as os, require_envvar=True may conflict with the claim that local DefaultAzureCredential works as-is, and handling for errors, timeouts, throttling, and invalid input is limited.
The skill clearly targets Python Azure Monitor, Log Analytics queries, and Azure metrics, with explicit trigger terms, clients, and sync/async scenarios. Points are deducted because non-fit boundaries, permission prerequisites, SDK compatibility ranges, Chinese-language guidance, and mainland-China network fit are not documented; service access may depend on region, network, and Azure configuration.
The evidence includes front matter, MIT licensing, version 1.0.0, installation and environment-variable notes, layered references, examples, and best practices. Repository context also shows official-organization provenance, maintenance language, and CI/evaluation workflows. Points are deducted because the skill lacks a changelog, explicit maintainer and update path, dependency/version guidance including optional pandas, FAQs, troubleshooting, and sufficient limitation disclosure; some reference guidance is generic and not query-specific.
The evidence provides patterns for logs, metrics, batching, partial results, aggregations, dimension filters, metric definitions, and async clients, offering useful coverage for common coding tasks. Points are deducted because no skill-specific output or end-to-end result is statically verifiable, examples have missing imports and context dependencies, and production guidance for retries, paging/limits, authorization failures, and result completeness is insufficient.
The evidence includes the selected skill and reference files, version metadata, MIT license, and repository-level testing and CI signals. Points are deducted because the supplied tests do not cover the skill's key Python query paths, no skill-specific acceptance criteria, pinned dependencies, or third-party execution evidence are shown, and important API claims rely mainly on author-provided documentation rather than corroborating sources.
- The examples may not run unchanged: at least the os import is missing, and require_envvar=True may conflict with the stated local-authentication guidance.
- Before production use, verify the azure-monitor-query version, API signatures, least-privilege RBAC, sensitive-data exposure in queried logs, and service reachability for the target network and region.
- Do not directly print, persist, or forward returned logs or metrics to other services without data classification, access controls, and user authorization.
What it does & when to use it
This is a Microsoft Agent Skills repository skill for the Azure Monitor Query SDK for Python. It guides coding agents through querying Log Analytics workspaces with LogsQueryClient and querying Azure resource metrics with MetricsQueryClient. The skill includes synchronous and asynchronous patterns, batch queries, partial-result handling, aggregations, dimension filters, metric metadata, and DataFrame conversion. It is a good fit for Python developers who already have Azure Monitor resources and need ready-to-adapt query examples with credential and client-lifecycle guidance.
Guides installation of azure-monitor-query and configuration of workspace, resource URI, and credential environment variables; generates synchronous or asynchronous Python client code using DefaultAzureCredential; runs Kusto queries against Log Analytics workspaces and supports batch log queries; handles successful, partial, and failed query states; queries Azure resource metrics with time spans and granularity; applies aggregations and dimension filters; lists metric definitions and namespaces; and converts log results into pandas DataFrames.
- A Python backend developer needs to summarize AppRequests or AppExceptions from a Log Analytics workspace.
- An operations engineer needs CPU, network, or request metrics for an Azure resource over a defined time range.
- A team needs to run multiple Kusto queries in one workflow and account for partial results.
- An asynchronous Python service needs Azure Monitor clients and credentials to be closed deterministically.
- A data engineer needs to move Azure Monitor query rows into pandas for analysis.
Pros & cons
- Covers both Log Analytics queries and Azure resource metrics.
- Provides synchronous and asynchronous examples with explicit client and credential lifecycle guidance.
- Includes practical patterns for batching, partial results, aggregations, dimension filters, and DataFrame conversion.
- Uses DefaultAzureCredential for portable local-development and Azure authentication patterns.
- Requires Azure Monitor or Log Analytics resources, identifiers, and valid credentials.
- The supplied material does not specify required Azure RBAC roles, quotas, or service costs.
- Python version, SDK version, and API compatibility details are not provided.
- The contents of the referenced capabilities.md and non-hero-scenarios.md files are not included in the source material.
How to install
Install the collection with npx skills add microsoft/skills, then select the required skill in the wizard. The README says skills are installed in the chosen agent directory, such as .github/skills/ for GitHub Copilot. Install the Python SDK package with pip install azure-monitor-query.
How to use
Give the coding agent a request such as: Use azure-monitor-query to query Log Analytics AppRequests from the last hour and summarize them by ResultCode. The documented trigger terms also include azure-monitor-query, LogsQueryClient, MetricsQueryClient, Kusto queries, and Azure metrics. Before use, provide AZURE_LOG_ANALYTICS_WORKSPACE_ID or AZURE_METRICS_RESOURCE_URI as appropriate and configure Azure credentials; production use is documented with AZURE_TOKEN_CREDENTIALS=prod.