Skip to content

Fix SPN support for refresh_semantic_model and takeover_item_ownership - #1286

Draft
m-kovalsky with Copilot wants to merge 3 commits into
mainfrom
copilot/fix-semantic-model-refresh-issue
Draft

Fix SPN support for refresh_semantic_model and takeover_item_ownership#1286
m-kovalsky with Copilot wants to merge 3 commits into
mainfrom
copilot/fix-semantic-model-refresh-issue

Conversation

Copilot AI commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

When running in a Fabric pipeline via Service Principal, refresh_semantic_model failed because it relied on sempy.fabric.refresh_dataset() / get_refresh_execution_details() — sempy functions that don't route through the SPN token provider set by service_principal_authentication.

Changes

  • refresh_semantic_model: Replaces fabric.refresh_dataset() and fabric.get_refresh_execution_details() with direct calls to the Power BI Enhanced Refresh REST API via _base_api(client="fabric_sp"). Error extraction likewise uses the REST API instead of sempy.
  • cancel_dataset_refresh: Replaces fabric.list_refresh_requests() with a direct REST API call; adds client="fabric_sp" to the delete request.
  • get_semantic_model_refresh_history: Adds client="fabric_sp" to the existing _base_api call.
  • takeover_item_ownership: Already used client="fabric_sp" correctly; docstring updated.
  • All four functions now document SPN support. The visualize=True path (XMLA trace) is noted as requiring interactive user context.

Usage

with sempy_labs.service_principal_authentication(
    key_vault_uri="https://your-keyvault.vault.azure.net/",
    key_vault_tenant_id="tenant-id-secret",
    key_vault_client_id="client-id-secret",
    key_vault_client_secret="client-secret",
):
    labs.takeover_item_ownership(item="MyModel", type="SemanticModel", workspace="MyWorkspace")
    labs.refresh_semantic_model(dataset="MyModel", workspace="MyWorkspace")

Copilot AI added 2 commits July 17, 2026 10:46
- Replace fabric.refresh_dataset() with direct Power BI REST API call via
  _base_api(client="fabric_sp") so SPN authentication is properly used
- Replace fabric.get_refresh_execution_details() with direct REST API calls
  for status polling and error extraction
- Update cancel_dataset_refresh to use _base_api(client="fabric_sp") and
  replace fabric.list_refresh_requests() with direct REST API call
- Add client="fabric_sp" to get_semantic_model_refresh_history _base_api call
- Add "Service Principal Authentication is supported" docstring to
  refresh_semantic_model, cancel_dataset_refresh, get_semantic_model_refresh_history,
  and takeover_item_ownership
- Note in visualize parameter that XMLA trace requires interactive user context
Copilot AI changed the title [WIP] Fix issue refreshing direct lake semantic model Fix SPN support for refresh_semantic_model and takeover_item_ownership Jul 17, 2026
Copilot AI requested a review from m-kovalsky July 17, 2026 10:48
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.

Unable to refresh a direct lake semantic model or take ownership of a semantic model

2 participants