/azure-core:log-analyticsfrom azure-core
Queries an Azure Monitor Log Analytics workspace read-only by az rest against the Logs query API (api.loganalytics.io/v1/workspaces/<id>/query), no CLI extension needed. Finds the workspace GUID (customerId) from its name or a Function app's Application Insights resource, writes the KQL to a file and posts it as a JSON body, prints the PrimaryResult table as TSV, and reads a PartialError, a 204 and the API's errors: BadArgumentError, SYN0002, SEM0100, InsufficientAccessError, InvalidAuthenticationTokenAudience, PathNotFoundError, 429, 504. Carries KQL templates for a Function app's logs in a workspace-based Application Insights: AppRequests failures, AppExceptions by ProblemId, AppTraces warnings, everything around a timestamp, one OperationId, executions parsed from Executed traces, FunctionAppLogs. Never writes to Azure, installs an extension or suggests an allow rule for az rest.
Ships in azure-core. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Runs KQL against a Log Analytics workspace through the Azure Monitor Logs
query API, by one az rest call per query, and prints the result as
TSV. It needs no CLI extension: az monitor log-analytics query is not
in core az, which lists only cluster, query-pack and workspace
under az monitor log-analytics (observed 2026-11-17, azure-cli 2.90.0),
and installing the extension is a write to the user's CLI that this
skill never makes.
Drilled from Microsoft Learn, local az 2.90.0 and Microsoft's public
demo workspace on 2026-11-17. The call, the TSV and the error shapes
ran against the demo workspace with its key; no query here has run with
a token, so the first real one is the check on step 1's lookup and
step 3's --resource.
Detail lives in references/: api.md (the request and response, the
error codes with what to do, the limits, the access a query needs) and
queries.md (KQL templates for a Function app's logs). Each cites the
Learn page behind its claims. Past them, Learn, by microsoft-learn-mcp
(microsoft_docs_search, then microsoft_docs_fetch), or with no
server, curl -sL -H 'Accept: text/markdown' <page URL> (undocumented,
read 2026-11-07). A live page that contradicts a line here wins: say so,
act on the page, and route the fix by capture-learning, bar a dated
measured line that names the page it overrules and the call that
measured it, which a page changed since its date sends back to
re-measure. An observed claim is cited or marked pending a doc check,
and stands, marked observed, only where no page covers it.
Not here. A Fabric Eventhouse or KQL database, which is
rti-items'. Granting a role, and a 401 or 403 past api.md's
table, which are access'. The Application Insights query API and a
classic Application Insights resource's own tables. Basic and Auxiliary
table plans, search jobs and restores. Any write to Azure.
Pin the tenant before any az call, as access says: set
AZURE_CONFIG_DIR to the directory kept for that tenant, since unset it
is the shared ~/.azure, then check az account show. Where a
user-scope CLAUDE.md names a directory per tenant, take that one.
The API takes the workspace's GUID, its customerId, never its ARM
resource ID
(request-format,
read 2026-11-17). From the workspace's name and resource group:
az monitor log-analytics workspace show -g <resource-group> -n <workspace> --query customerId -o tsv
That is Learn's own lookup, in its Container Apps and Container
Instances samples (read 2026-11-17); --ids <workspace-resource-id>
replaces -g and -n.
From a Function app, go through its Application Insights resource,
whose WorkspaceResourceId names the workspace (Learn's
containers/kubernetes-open-protocol sample, read 2026-11-17). List
the resource group's Application Insights resources, then read the one
the app uses:
az resource list -g <resource-group> --resource-type Microsoft.Insights/components --query "[].name" -o tsv
az resource show -g <resource-group> -n <app-insights> --resource-type Microsoft.Insights/components --api-version 2020-02-02 --query properties.WorkspaceResourceId -o tsv
Then workspace show --ids with that ID. az monitor app-insights is
an extension too, absent from core (observed 2026-11-17, azure-cli
2.90.0). An empty WorkspaceResourceId is a classic resource, whose
telemetry this skill does not query (reported: microsoft/azure-skills
azure-diagnostics, 2026-11-17). FunctionAppLogs follows the app's
diagnostic setting instead
(monitor-functions,
read 2026-11-17), whose workspaceId names its workspace; with none,
stop and say so. The --query path is untried against a real app
(2026-11-17):
az monitor diagnostic-settings list --resource <function-app-resource-id> --query "[].workspaceId" -o tsv
Read no app settings to find it: their values print in full.
Write the KQL with the Write tool to <scratchpad>/query.kql, from
a template in references/queries.md or whole. Then build the body:
jq -b -n --rawfile q "<scratchpad>/query.kql" --arg t "PT1H" '{query: $q, timespan: $t}' > "<scratchpad>/body.json"
The KQL reaches no command line, jq's included, so its quotes and
pipes need no escaping and its length meets no argument limit (observed
2026-11-17, jq 1.8.2). -b stops native Windows jq writing CRLF.
Always pass a timespan: omitted, the query reads all data
(request-format,
read 2026-11-17). It is an ISO 8601 duration, PT6H or P1D, or a
start/end pair of UTC times ending Z. Times in results end Z too
(observed 2026-11-17, azure-cli 2.90.0): say a moment in UTC, and
convert the user's local time before writing it.
Spell the scratchpad as a Windows path, C:/…, wherever az reads
it: az is a native program, and the demo runs read @C:/… bodies
(observed 2026-11-17, azure-cli 2.90.0).
az rest --method post --url "https://api.loganalytics.io/v1/workspaces/<workspace-guid>/query" --resource "https://api.loganalytics.io" --headers "Content-Type=application/json" --body "@<scratchpad>/body.json" --only-show-errors > "<scratchpad>/result.json"
This is Learn's POST sample, host and --resource paired
(request-format, read 2026-11-17): the token's audience is
https://api.loganalytics.io. api.loganalytics.azure.com is the newer
host, but az derives no token resource from it (observed 2026-11-17,
azure-cli 2.90.0), so keep the pair as written.
A query that may run past 3 minutes adds "Prefer=wait=600" to
--headers, beside the Content-Type: 3 minutes is the default and 10
the most, and past its wait the API answers 504
(timeouts,
read 2026-11-17).
Each query asks the user's permission, and that stays so. No allow
rule makes az rest read-only: given --method get then --method post, az sends the last, so a rule on a GET prefix approves a write,
and --resource attaches the token to whatever host --url names
(observed 2026-10-27, azure-cli 2.90.0). Suggest no rule for it.
jq -b -r '.tables[0] | (.columns | map(.name)), .rows[] | @tsv' "<scratchpad>/result.json"
jq -b -c '.error // empty' "<scratchpad>/result.json"
The first prints a header and the rows, a tab or newline inside a cell
escaped as \t or \n (observed 2026-11-17, jq 1.8.2). The second
prints nothing on a full result; a PartialError arrives with a
200 and tables that may be incomplete
(response-format,
read 2026-11-17): report it beside the rows.
result.json is a 204, a workspace with no data, or an
empty 200, a POST without its JSON body or Content-Type
(timeouts, read 2026-11-17). Check the body file before blaming the
workspace.take before printing, and never page
a large table into the conversation.ERROR: Bad Request({…}), and nothing on stdout. The innermost code says why:
SYN0002 is a parse error at the line and pos it names, SEM0100
a table or column the workspace lacks (observed 2026-11-17, azure-cli
2.90.0). api.md's table has every code and what to do.A workspace-based Application Insights resource writes AppRequests,
AppDependencies, AppTraces and AppExceptions, filtered by
AppRoleName, and FunctionAppLogs exists only where a diagnostic
setting sends it: references/queries.md says which, with the
classic-name map. Its templates, each run against the demo workspace:
| Template | Answers |
|---|---|
summary | which apps and tables hold rows; run first, to learn the AppRoleName |
failures | failed requests by operation and result code |
exceptions | exceptions grouped by ProblemId |
warnings | traces at Warning or above |
around | the 200 rows nearest a moment, in order |
operation | everything one OperationId logged |
executions | runs, results and durations parsed from Executed lines |
function-app-logs | the platform log's warnings and errors |
kql | anything else, written whole |
Start a failure at around or failures, then follow an
OperationId with operation: the first two find the rows, the third
tells their story.
/query path; the lookups are show and list. Never pass az rest
another method or host, and never install an extension: if the user
wants az monitor log-analytics query, installing it is theirs.az rest, for the reason step 3 gives.What SKILL.md sets; muted values are Claude Code's defaults
Use when asked to read, query or search Log Analytics, Azure Monitor logs, Application Insights or a Function app's logs and traces from the terminal, to run KQL against a workspace, to find why a function failed at a given time, or when az monitor log-analytics query is missing or wants to install an extension, or when asked for an allow rule so its az rest queries stop prompting for permission. Not for a Fabric Eventhouse or KQL database (rti-items), nor for granting Log Analytics Reader (access).
Other plugins' skills for the same job
2 skills in this plugin
npx claudepluginhub wardawgmalvicious/claude-plugins --plugin azure-core