Introducing a new way to review your PRs.

Read the announcement

floci-io / floci-az

Light, fluffy, and always free - Local Azure Emulator

View on GitHub

27 documents · Updated Nov 23, 2026

docs / azure-resource-graph

Azure Resource Graph

Azure Resource Graph gives clients a local query view over emulator resources and related control-plane data. It accepts Resource Graph requests, builds graph tables from current emulator stores, evaluates a supported KQL subset, and returns paged results in the Azure response shapes.

Resource Graph service surface

The Resource Graph service has two related control-plane paths. The POST .../providers/Microsoft.ResourceGraph/resources action runs a query, while Microsoft.ResourceGraph/queries represents saved shared queries in a resource group. The service is available only when the Resource Graph service setting is enabled.

The shared-query resource is global in behavior but is addressed under a subscription and resource group. It supports the normal resource lifecycle:

  • GET lists a collection or reads one saved query.
  • PUT creates or replaces a query.
  • PATCH updates its query text, description, or tags.
  • DELETE removes it.

The saved representation keeps the query text and description in properties. Shared queries also enter the ARM resource index, so normal subscription and resource-group views can discover them and resource-group deletion can remove them. The in-memory store is cleared by emulator reset.

References: src/…/ResourceGraphArmSurface.java• L12-28 src/…/ResourceGraphHandler.java• L30-69 src/…/SharedQueries.java• L24-35 src/…/SharedQueries.java• L82-107

Query request flow

The query action turns a request body into a KQL query, narrows the graph-table view when needed, evaluates the query, and then applies page options to the result. The flow is:

flowchart LR
    A[Resource Graph POST] --> B[Validate query and options]
    B --> C[Parse KQL]
    C --> D[Build scoped graph tables]
    D --> E[Run local KQL engine]
    E --> F[Page rows]
    F --> G[Return objectArray or table]

The request can name subscriptions. When it does not, the query sees all subscriptions known to the graph tables. When it does, rows with a matching subscriptionId remain in scope; rows without a subscription remain visible. $top is limited to 1,000 rows, and $skip or $skipToken moves through later pages. The response reports totalRecords, count, data, empty facets, and resultTruncated: false; a later page receives a URL-safe skip token. Invalid bodies, empty queries, out-of-range $skip values, invalid skip tokens, parse errors, and semantic errors return HTTP 400 responses with Resource Graph error details.

References: src/…/ResourceGraphHandler.java• L72-145 src/…/ResourceGraphHandler.java• L147-175

Graph table assembly

Graph tables are rebuilt for each query from the emulator's current stores. This keeps query results aligned with resources created or removed through the emulator's other control-plane services instead of maintaining a separate Resource Graph copy. Each table is assembled on first use and then held for the rest of that query, so union and join operations see one consistent view. Container rows also reflect management-group state when that service is enabled.

TableSource and purpose
resourcesARM-indexed resources across known subscriptions.
resourcecontainersManagement-group, subscription, and resource-group rows. Subscription rows include their management-group ancestor chain when enabled.
policyresourcesPolicy definitions, initiatives, assignments, and exemptions from the policy store.
authorizationresourcesAn empty table because authorization role data is not stored.

Resource rows expose the standard graph columns such as id, name, type, tenantId, location, resourceGroup, subscriptionId, properties, and tags. The graph normalizes type, location, and resource-group names to lower case. Management-group rows are tenant-level and do not belong to a subscription or resource group. Policy rows are marked with kind: policy and exclude internal store fields.

References: src/…/GraphTables.java• L27-38 src/…/GraphTables.java• L63-113 src/…/GraphTables.java• L115-215 src/…/GraphTables.java• L217-326

Local KQL query engine

The local KQL engine is the execution layer between graph tables and the response formatter. The parser converts a query into a syntax tree, and the engine applies each pipeline operation to new row lists without changing source tables. It also tracks the columns that each pipeline stage can produce, which lets it reject unknown names early and preserve result columns when a join side has no rows.

The supported query model covers the main Resource Graph patterns:

  • Table reads and nested queries.
  • Filtering, calculated columns, projection, column removal, and row limits.
  • Grouping and aggregation through summarize.
  • Sorting and distinct rows.
  • union and several join kinds.
  • Counts and expressions over scalar or nested dynamic values.
  • Stable output-column names for empty projections, summaries, and unmatched join rows.

The engine checks table names, column names, functions, and aggregation functions before it runs a pipeline. It follows Kusto-like null behavior for filters and comparisons. The scalar function set covers text, conversion, date-time, collection, dynamic-object, regex, numeric, and conditional operations. Null checks and fallback expressions help queries handle missing values within the same pipeline.

KQL values use a small local type model: strings, integers, numbers, booleans, datetimes, timespans, null, and dynamic maps or lists. Failed conversions produce null. Dynamic properties use case-sensitive keys, while top-level column lookup is case-insensitive. Datetimes and timespans are converted to JSON-safe text only when the result is serialized.

References: src/…/Kql.java• L12-23 src/…/Kql.java• L323-333 src/…/KqlEngine.java• L47-96 src/…/KqlEngine.java• L99-195 src/…/KqlEngine.java• L390-414 src/…/KqlEngine.java• L637-845 src/…/KqlFunctions.java• L22-38 src/…/KqlValues.java• L21-25

Query result formats

Resource Graph supports two result layouts. objectArray returns each row as an object. table returns column metadata and row value arrays. The table layout derives output columns from the evaluated query and infers each column's type from the available values, while empty projections and summaries retain their known output names.

References: src/…/ResourceGraphHandler.java• L177-215 src/…/KqlEngine.java• L367-405 src/…/KqlValues.java• L333-363

Change checklist

When these files or sections are changed, remember to consider these:

  • Changes to graph table names or published columns must stay aligned with table lookup, column validation, subscription scoping, and table-format output.
  • Changes to management-group enablement or hierarchy must stay aligned with container rows and subscription ancestor chains.
  • Changes to shared-query indexing must preserve generic ARM listing and resource-group deletion behavior.
  • Changes to KQL value conversion must be checked against expression comparison, aggregation, and JSON result serialization together.
  • Changes to query paging must preserve the relationship between $skip, $skipToken, count, totalRecords, and the selected result format.

Important failure modes

TriggerConsequenceGuard
A query names an unsupported table, column, function, or aggregation.The query returns HTTP 400 with an InvalidQuery detail.Use the published graph tables and supported KQL subset.
A shared query is addressed without a resource group.The request returns ResourceNotFound because shared queries are resource-group resources.Use the subscription/resource-group/provider/resource path.
$skipToken is malformed or $skip is outside its valid range.The request returns HTTP 400 and no page is returned.Reuse the token from the prior response and keep skip values non-negative and bounded.
A resource type or location is compared with unexpected casing.A case-sensitive query may not match the normalized graph value.Account for lower-case type, location, and resourceGroup values.
Management groups are disabled or their parent links are incomplete.Management-group rows or subscription ancestor chains are absent or incomplete.Check the management-group service state and hierarchy before relying on those fields.

Key files

FileWhy to read it
src/…/ResourceGraphHandler.javaEntry point for query requests, scoping, paging, errors, and result formats.
src/…/GraphTables.javaDefines the graph tables and connects them to emulator resource stores.
src/…/SharedQueries.javaDefines shared-query lifecycle handling and ARM index integration.
src/…/Kql.javaDefines the supported KQL syntax and query model.
src/…/KqlEngine.javaApplies query operators, validates names, tracks output columns, and determines result shape.
src/…/KqlFunctions.javaProvides supported scalar functions, conversions, and null-aware query expressions.
src/…/KqlValues.javaDefines value conversion, comparison, and JSON behavior.
docs/azure-platform-services.mdParent page for the emulator's Azure platform service model.
docs/arm-resource-governance.mdRelated page for ARM resource indexing and governance behavior.
docs/azure-policy-service.mdRelated page for the policy data that feeds policyresources.
docs/azure-policy-insights.mdRelated page for policy resources and query context exposed alongside the graph tables.
docs/azure-ai-search.mdSibling page for another Azure data query service.
docs/azure-iot-hub.mdSibling page for another Azure platform service.
docs/azure-signalr-service.mdSibling page for another Azure platform service.
docs/azure-authorization-rbac.mdRelated page for authorization data that is not populated in authorizationresources.