Skip to main content

Microsoft Fabric

Prerequisites
  • A Microsoft Entra tenant and permission to register an app, or an administrator who can do this for you.
  • A VIKTOR environment administrator who can create OAuth 2.0 integrations.
  • Power BI. You need access to the workspace and semantic model. To run queries, the signed-in user needs Read and Build permissions on the model. Your tenant must enable Dataset Execute Queries REST API. See Power BI query permissions.
  • OneLake. You need a lakehouse in a workspace on active Fabric capacity. The signed-in user needs read access to the data, and your tenant must allow external access to OneLake. See OneLake tenant settings and lakehouse permissions.

Microsoft Fabric is Microsoft's cloud platform for data and analytics. It includes tools to collect data with pipelines, process it in notebooks, query it in SQL warehouses, and build reports in Power BI. Teams organize these items in workspaces. OneLake is the shared storage layer for Fabric data, including lakehouse files and tables. See Microsoft Fabric overview and OneLake overview.

What your VIKTOR app needs to doAPI to use
Browse Fabric workspaces and find items such as lakehouses, notebooks, or semantic models.Fabric REST API
Run a DAX query on a Power BI semantic model. The model can use data in OneLake or another data source.Power BI REST API
List or read files in a lakehouse.OneLake through the Azure Data Lake Storage API

Each API in the table uses a different access token. In VIKTOR, create one OAuth 2.0 integration for each API your app calls. The scopes in each integration identify the target API and the permissions to request. For example, an app that uses the Fabric REST API to find a lakehouse and OneLake to read its files needs two VIKTOR integrations. Both can use the same Microsoft Entra app registration. See Microsoft Entra access tokens.

Follow the setup steps:

  1. Register an app in Microsoft Entra.
  2. Add API permissions.
  3. Create the VIKTOR integrations.
  4. Implement the integration.

Register an app in Microsoft Entra​

  1. Open Microsoft Entra app registrations and sign in to your organization.
  2. Select New registration.
  3. Enter a name, select the supported account types, and select Web as the redirect platform.
  4. Enter the callback URL of your VIKTOR environment and select Register.
  5. On the Overview page, copy the Application (client) ID and Directory (tenant) ID.

The callback URL has this format. Replace <your-viktor-environment> with your environment host and keep the final slash:

https://<your-viktor-environment>/api/integrations/oauth2/callback/

For more details, see Registering an application in Microsoft Entra.

For this guide, register an application named viktor-fabric-integration, as shown below. Use your own tenant and VIKTOR callback URL.

Microsoft Entra app registration with a VIKTOR web redirect URI

note

The screenshots use demo.viktor.ai as an example. Replace it with the address of your VIKTOR environment when you configure the callback URL and open the integration settings.

Create a client secret​

  1. In the app registration, go to Certificates & secrets > Client secrets and select New client secret.

  2. Enter a description, select when the secret expires, and select Add.

    Microsoft Entra client secrets page with the Add a client secret form open

  3. In the Client secrets table, select the copy icon in the Value column. Use this value as the Client secret in VIKTOR. You cannot view the value again after you leave the page.

    Microsoft Entra client secrets table with the Value column and its copy icon highlighted

Add API permissions​

Add delegated permissions so VIKTOR can use the APIs on behalf of the signed-in user. You can add the permissions from both tabs to the same Microsoft Entra app registration.

  1. Open Microsoft Entra app registrations.
  2. Select your app registration.
  3. Select API permissions > Add a permission.
  1. In Request API permissions, open Microsoft APIs and select Power BI Service. In this picker, Power BI Service also includes delegated permissions for the Fabric REST API.

    Microsoft API selection with Power BI Service highlighted

  2. Select Delegated permissions. To list workspaces in Power BI or Fabric, search for Workspace.Read.All and select its checkbox. The Fabric REST API also uses this permission to list items in a workspace. See List Fabric workspace items.

    Select the Power BI Service workspace permission in Microsoft Entra

  3. If your app reads or queries Power BI semantic models, search for Dataset.Read.All in the same panel and select its checkbox. To run a query, the signed-in user also needs Read and Build permissions on the model. See Power BI query permissions.

    Select the Power BI semantic model permission

  4. Select Add permissions to save your selection.

Return to API permissions and check the Configured permissions list. Each permission appears under its API. The screen below shows an app registration with permissions for both Power BI Service and Azure Storage.

Configured API permissions with Azure Storage and Power BI Service highlighted

If your organization requires administrator consent, ask a Microsoft Entra administrator to grant it. Give users access to the workspaces, semantic models, or files that the app uses.

Create the VIKTOR integrations​

Create a separate Generic OAuth 2.0 integration in VIKTOR for each API your app calls. For example, if your app queries Power BI and reads OneLake files, create both power-bi and microsoft-onelake.

If you use the same Microsoft Entra app registration for both, use the same Authentication URL, Token URL, Client ID, and Client secret. Give each integration its own name and use the scopes for its API.

  1. Open your VIKTOR environment and select Administrator > Integrations > OAuth 2.0. On demo.viktor.ai, open VIKTOR integrations.
  2. Select Add OAuth 2.0 integration > Generic.
  3. Enter a name and select the VIKTOR apps that can use the integration.
  4. Select Next and enter the authentication URL, token URL, client ID, client secret, and the scopes for the target API.
  5. Select Create. Repeat for each API that your app needs.

For more details, see Creating an OAuth 2.0 integration.

In the Add OAuth 2.0 integration dialog, select Generic.

The VIKTOR OAuth 2.0 integration dialog with Generic marked by a blue circle

In Basic information, enter an integration name and select the VIKTOR apps that can use it. The image shows a Fabric integration; use a distinct name for each integration you create.

To limit the integration to selected apps, set Scope to Specific and select those apps.

Set the name and app availability of a VIKTOR integration

In Configuration, enter the following values. Replace <tenant-id> with your Directory (tenant) ID.

FieldValue
Authentication URLhttps://login.microsoftonline.com/<tenant-id>/oauth2/v2.0/authorize
Token URLhttps://login.microsoftonline.com/<tenant-id>/oauth2/v2.0/token
Client IDThe Application (client) ID from Entra
Client secretThe client secret value from Entra

Enter each scope separately and press Enter after each value.

Configure API scopes​

Use the Fabric REST API to list Fabric items such as lakehouses, Power BI to query semantic models, and OneLake to access files.

To list Fabric workspaces and their items, create an integration such as microsoft-fabric with these scopes:

offline_access
https://api.fabric.microsoft.com/Workspace.Read.All

See List workspaces for the required access and response format. Other Fabric API operations can require additional permissions. See Fabric REST API scopes.

Configure the Fabric OAuth integration in VIKTOR

Other Fabric REST API scopes​

Use the https://api.fabric.microsoft.com/ prefix for these scopes in VIKTOR. Check Required Delegated Scopes for the operation in the Fabric REST API reference.

ScopeWhat it allows
Workspace.ReadWrite.AllRead and write workspaces.
Item.Read.All, Item.ReadWrite.AllRead Fabric items, or read and write them.
Item.Execute.All, Item.Reshare.AllExecute or reshare eligible Fabric items.
Lakehouse.Read.All, Notebook.Read.AllRead the specified item type.

Other Fabric services​

Fabric also includes Data Factory, Data Engineering, Data Science, Data Warehouse, Databases, and Real-Time Intelligence. The Fabric REST APIs can manage supported items and jobs in these services. Some services expose other interfaces, such as SQL or service-specific APIs, with their own permissions and access requirements. Choose the API for the operation you need.

Implementing the integration (Developer)​

Use this requirements.txt for all three examples.

viktor
requests

Set registered_name to your app's registered name. Use the same integration name in oauth2_integrations and OAuth2Integration. Connect the integration from the app's Integrations menu.

This app lists the workspaces available to the signed-in user. Select a workspace to see its items, such as lakehouses, notebooks, and reports. Both requests use Workspace.Read.All through the same Fabric REST API integration.

  1. Create an app with this viktor.config.toml.
app_type = "editor"
python_version = "3.13"
registered_name = "your-app-name"
oauth2_integrations = ["microsoft-fabric"]
  1. Add this code to app.py:
import requests
import viktor as vkt


def list_fabric_entries(path):
token = vkt.external.OAuth2Integration("microsoft-fabric").get_access_token()
url = f"https://api.fabric.microsoft.com/v1/{path}"
headers = {"Authorization": f"Bearer {token}"}
entries = []
query = {}

while True:
response = requests.get(url, headers=headers, params=query, timeout=30)
response.raise_for_status()
page = response.json()
entries.extend(page["value"])
continuation = page.get("continuationToken")
if not continuation:
return entries
query = {"continuationToken": continuation}


def workspace_options(params, **kwargs):
return [
vkt.OptionListElement(value=workspace["id"], label=workspace["displayName"])
for workspace in list_fabric_entries("workspaces")
]


class Parametrization(vkt.Parametrization):
workspace = vkt.OptionField("Workspace", options=workspace_options)


class Controller(vkt.Controller):
parametrization = Parametrization

@vkt.TableView("Workspace items")
def workspace_items(self, params, **kwargs):
if not params.workspace:
raise vkt.UserError("Select a workspace.")
items = list_fabric_entries(f"workspaces/{params.workspace}/items")
return vkt.TableResult(
[[item["displayName"], item["type"], item["id"]] for item in items],
column_headers=["Item", "Type", "Item ID"],
)
  1. Start the app, connect the Fabric integration, select a workspace, and open Workspace items. You need at least the Viewer role for the selected workspace. See List workspaces and List items.

    Fabric workspace browser showing two semantic models in the selected workspace

FAQs​

Why does Microsoft sign-in fail?

Check the redirect URI, client secret, and API permissions in Entra and VIKTOR. Reconnect the integration after changing scopes.

If Microsoft reports AADSTS650052, ask your Entra administrator to check that the API is available in the tenant and that consent is granted. If the error names a missing Azure Storage service principal, check Enterprise applications. See Microsoft's consent troubleshooting.

Why does my Power BI query return 403 Forbidden?

Use the Power BI token with Dataset.Read.All. Check the user's workspace access, Read and Build permissions on the semantic model, and the Dataset Execute Queries REST API tenant setting.

Why does OneLake return 403 Forbidden?

Use the Azure Storage token from your OneLake integration. Check that the workspace has active Fabric capacity, that the user can read the lakehouse data, and that the tenant allows external OneLake access. See OneLake data access.

Why does OneLake return 401 Unauthorized?

Check that the OneLake integration requests https://storage.azure.com/user_impersonation, then reconnect it.

Why does OneLake return 404 Not Found?

Check the workspace ID, lakehouse ID, and file path. You can also copy the file URL from its properties in Fabric. See Copy a OneLake file URL.