Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 10, 2025

Description

Adds detection and guidance for destructive semantic model changes (schema modifications causing data loss), plus automatic refresh after deployment via parameter.yml configuration. Both features are opt-in via feature flags.

Implementation

Feature Flags (Required)

Both features require explicit opt-in via feature flags:

  • enable_semantic_model_destructive_change_detection - Enables destructive change detection
  • enable_semantic_model_refresh - Enables automatic refresh after deployment
from fabric_cicd import append_feature_flag

# Enable destructive change detection
append_feature_flag("enable_semantic_model_destructive_change_detection")

# Enable semantic model refresh
append_feature_flag("enable_semantic_model_refresh")

Destructive Change Handling

  • Detects Alm_InvalidRequest_PurgeRequired and similar errors by code and message keywords
  • Logs actionable resolution steps: XMLA endpoint ClearValues, delete/recreate, or schema revert
  • Fails deployment explicitly to prevent accidental data loss
  • Only active when enable_semantic_model_destructive_change_detection flag is enabled

Automatic Refresh

  • New semantic_model_refresh parameter supports single/multiple models
  • Default full refresh or custom payloads (partition-based, incremental for Premium)
  • Uses Power BI REST API; non-blocking (deployment continues if refresh fails)
  • Only active when enable_semantic_model_refresh flag is enabled

Core Changes

  • _is_destructive_change_error(): Error detection with type-safe string validation
  • _publish_semanticmodel_with_retry(): Enhanced deployment with guidance logging
  • _refresh_semanticmodels_if_configured(): Config parser for refresh settings with feature flag check
  • _refresh_semanticmodel(): Executes refresh via Power BI API
  • publish_semanticmodels(): Updated to check feature flags before enabling new functionality

Documentation

Added comprehensive deployment guide (semantic_model_deployment.md):

  • Feature flag requirements and usage instructions
  • Destructive change types and resolution workflows
  • XMLA endpoint examples (Tabular Editor, SSMS, PowerShell)
  • Refresh configuration patterns and best practices

Updated parameterization.md with semantic_model_refresh parameter specification and feature flag requirements.

Example Usage

# parameter.yml
semantic_model_refresh:
  - semantic_model_name: "Sales Model"  # Default full refresh
  
  - semantic_model_name: "Marketing Model"
    refresh_payload:  # Premium capacity advanced options
      type: "full"
      objects:
        - table: "Sales"
        - table: "Products"
          partition: "Products-2024"
      commitMode: "transactional"
      maxParallelism: 2

Testing

15 new tests covering error detection, deployment retry, default/custom refresh payloads, multi-model configurations, and feature flag behavior. All 461 tests pass.

Linked Issue (REQUIRED)

Original prompt

This section details on the original issue you should resolve

<issue_title>Allow Destructive Changes to Semantic Model Deployments</issue_title>
<issue_description>### What is the feature?

Currently there is a known limitation that semantic model deployments that would result in data deletions are blocked.

Can we add a feature that does the following:

  • Try to deploy the model, if successful, nothing else to do 🙂
  • If it fails, and the API response shares the objects that are blocking the deployment, run a process ClearValues on those objects, and then try deploying the model again
  • If the API does not expose the objects, use the AMO nuget package or TE2 executable to deploy the TMDL/TMSL to the target semantic model
  • After deployment, have an option to also refresh the target model. The default should be process Automatic/Default, but it would be nice for the users to be able to customize the json body - > https://learn.microsoft.com/en-us/rest/api/power-bi/datasets/refresh-dataset#example-of-refreshing-one-partition

Additional context

No response</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Add support for destructive changes in semantic model deployments Fixes #574 - Add semantic model destructive change detection and refresh support Dec 10, 2025
Copilot AI requested a review from shirasassoon December 10, 2025 09:22
@shirasassoon
Copy link
Contributor

@copilot Hide this logic under a feature flag

Copy link
Contributor Author

Copilot AI commented Dec 10, 2025

@copilot Hide this logic under a feature flag

Done! Added two feature flags:

  • enable_semantic_model_destructive_change_detection - Controls destructive change detection
  • enable_semantic_model_refresh - Controls automatic refresh after deployment

Documentation updated with usage examples. Commit: 9294608

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow Destructive Changes to Semantic Model Deployments

2 participants