Edit

Handle errors when automating with the Fabric Maps REST API

Automating Fabric Maps commonly involves visualizing real-time or near-real-time operational data, such as work orders, telemetry, or status events ingested through Eventstreams and stored in an Eventhouse. These maps are often created and updated programmatically as part of deployment pipelines or solution automation.

Because Fabric Maps automation spans multiple steps—creating map items, applying map definitions, and binding layers to real-time data sources—errors can occur at different stages and for different reasons. Effective error handling helps automation workflows fail in a predictable way and provide clear diagnostics. It also prevents maps from being deployed with incomplete configuration or incorrect connections to streaming data.

This article describes error-handling best practices specific to Fabric Maps REST API workflows, with an emphasis on Eventhouse-backed, real-time maps.

Common failure scenarios when automating Fabric Maps

When working with real-time Fabric Maps, failures often extend beyond basic REST API availability. Common scenarios include:

  • Map creation succeeds, but applying the map definition fails due to invalid configuration.
  • Map definitions reference Eventhouse tables or columns that don't exist yet.
  • KQL-based layer sources are syntactically invalid or reference renamed fields.
  • Eventstreams are deployed after map definitions are applied, leaving layers temporarily unbound.
  • Repeated map definition updates during iterative development trigger API throttling.

Identifying whether a failure occurred during map creation, definition assignment, or data binding is critical for resolving it correctly.

Understanding error categories in real-time map automation

Errors encountered while automating Fabric Maps generally fall into three categories.

Configuration errors

Configuration errors indicate problems in the map definition itself, such as:

  • Invalid map.json structure.
  • Mismatched layerSources and layerSettings identifiers.
  • Unsupported layer types or options.
  • Invalid KQL queries for Eventhouse-backed layers.

These errors represent issues in the map definition and must be corrected before retrying the operation.

Data-pipeline timing errors

In real-time scenarios, REST calls can be valid but required data assets aren't yet ready. Examples include:

  • The Eventhouse exists, but the target table doesn't exist.
  • Columns referenced by the map definition aren't available yet.
  • Eventstream ingestion is running, but no data is available.

Retries can succeed after the data pipeline stabilizes, but only if the underlying map configuration is correct.

Recoverable platform errors

Recoverable errors include transient failures such as:

  • 429 Too Many Requests during bulk map updates.
  • Temporary service unavailability when applying map definitions.
  • Network-level connectivity failures.

These errors can often be retried safely with appropriate backoff.

Errors you shouldn't retry

Some errors never resolve through retries and must fail immediately:

  • Invalid or schema-incompatible map.json definitions.
  • Invalid KQL queries for Eventhouse-backed layer sources.
  • References to nonexistent Eventhouse tables, columns, or connections.
  • Permission or role assignment failures.
  • Conflicts such as duplicate map display names.

Retrying these errors can mask real problems in map definitions or data pipelines and delay remediation.

Retry-safe scenarios for real-time workflows

Retries are appropriate only when the failure is expected to resolve without configuration changes. Examples include:

  • 429 Too Many Requests responses during repeated map definition updates.
  • 503 Service Unavailable or 504 Gateway Timeout responses.
  • Temporary delays while Eventhouse ingestion or provisioning completes.

When retrying requests:

  • Honor the Retry-After response header when present.
  • Use exponential backoff.
  • Limit the maximum number of retries.

Important

Retrying REST calls does not resolve schema mismatches or missing Eventhouse assets. Use retries only for platform-level availability issues.

Structured error handling for Fabric Maps automation (Python)

The following example demonstrates structured error handling when creating or updating a map that includes Eventhouse-backed layers.

import httpx

def call_fabric_maps_api(method, url, headers, payload=None):
    try:
        response = httpx.request(
            method=method,
            url=url,
            headers=headers,
            json=payload,
            timeout=30
        )
        response.raise_for_status()
        return response.json()

    except httpx.HTTPStatusError as ex:
        status = ex.response.status_code
        details = ex.response.text

        print("Fabric Maps REST API call failed")
        print("HTTP status:", status)
        print("Response details:", details)

        # Fail fast for configuration and authorization errors
        if status in (400, 401, 403):
            raise

        # Allow caller to implement retry logic for transient failures
        raise

    except httpx.RequestError as ex:
        print("Network error while calling Fabric Maps REST API")
        print(str(ex))
        raise