### Start Mirrored Database Source: https://microsoft.github.io/fabric-cli/examples/item_examples Shows how to start a `.MirroredDatabase` synchronously. The command prompts for confirmation unless the '-f' flag is used to force the action. ```bash fab:/ws1.Workspace$ start mir1.MirroredDatabase ? Are you sure? Yes Starting 'mir1.MirroredDatabase'... * 'mir1.MirroredDatabase' started fab:/ws1.Workspace$ start mir1.MirroredDatabase -f ! Executing force start Starting 'mir1.MirroredDatabase'... * 'mir1.MirroredDatabase' started ``` -------------------------------- ### Fabric API Examples Source: https://microsoft.github.io/fabric-cli/examples/api_examples Demonstrates interacting with the core Fabric REST API for managing workspaces, lakehouses, and notebooks. Includes examples for GET, POST requests with inline JSON or local file paths for request bodies. ```bash # get Fabric workspaces fab:/$ api workspaces ``` ```bash # get all lakehouses in a workspace fab:/$ api -X get workspaces/762811e8-e364-4817-9557-f2ca363661cb/lakehouses --show_headers ``` ```bash # create an empty notebook in a workspace using inline JSON fab:/$ api -X post workspaces/762811e8-e364-4817-9557-f2ca363661cb/lakehouses -i {"displayName": "nbapi"} ``` ```bash # create an empty notebook in a workspace using local JSON path fab:/$ api -X post workspaces/762811e8-e364-4817-9557-f2ca363661cb/lakehouses -i /tmp/test.json ``` ```bash # Upload a whl file to a staging environment using local path fab:/$ api -X post workspaces/762811e8-e364-4817-9557-f2ca363661cb/environments/b12cd397b-e500-788j-ae53-1b0008014120/staging/libraries -i /tmp/mylib.whl ``` -------------------------------- ### Start Notebook Job with Inline Configuration Source: https://microsoft.github.io/fabric-cli/examples/job_examples Starts a notebook job asynchronously, passing configuration details as inline JSON. This is useful for setting up environment-specific parameters before execution. ```bash fab:/$ job start ws1.Workspace/nb1.Notebook -C { "defaultLakehouse": { "name": "", "id": "" }, "useStarterPool": false, "useWorkspacePool": "" } ``` -------------------------------- ### Get and Query Gateway Details Source: https://microsoft.github.io/fabric-cli/examples/gateway_examples Illustrates retrieving gateway details in JSON format and querying specific properties using JMESPath with the 'get' command. ```bash # get JSON properties fab:/$ get .gateways/gw1.Gateway # query using JMESPath fab:/$ get .gateways/gw1.Gateway -q . -o /tmp ``` -------------------------------- ### Get and Query Connection Details Source: https://microsoft.github.io/fabric-cli/examples/connection_examples Illustrates how to retrieve connection details using the 'get' command. Supports fetching raw JSON properties or querying specific details using JMESPath with the '-q' option. ```bash # get JSON properties fab:/$ get .connections/conn1.Connection # query using JMESPath fab:/$ get .connections/conn1.Connection -q . -o /tmp ``` -------------------------------- ### Start Fabric Capacity Source: https://microsoft.github.io/fabric-cli/examples/capacity_examples Starts a Fabric capacity synchronously. The `-f` flag can be used to force the operation. This command requires confirmation unless forced. ```bash fab:/$ start .capacities/capac1.Capacity ? Are you sure? Yes Starting 'capac1.Capacity'... * 'capac1.Capacity' started fab:/$ start .capacities/capac1.Capacity -f ! Executing force start Starting 'capac1.Capacity'... * 'capac1.Capacity' started ``` -------------------------------- ### Get and Query Fabric CLI Capacity Details Source: https://microsoft.github.io/fabric-cli/examples/capacity_examples Illustrates how to retrieve and query capacity details using the 'get' command. Supports JMESPath queries with the '-q' flag and output redirection to local paths or 'Lakehouse/Files' using '-o'. This functionality is compatible with F SKUs. ```bash # get JSON properties fab:/$ get .capacities/capac1.Capacity # query using JMESPath fab:/$ get .capacities/capac1.Capacity -q . -o /tmp ``` -------------------------------- ### ARM API for Fabric Capacities Examples Source: https://microsoft.github.io/fabric-cli/examples/api_examples Illustrates interacting with the Azure Resource Manager (ARM) REST API specifically for Fabric capacities. Examples cover listing capacities by subscription and listing available SKUs. ```bash # list by subscription fab:/$ api -A azure subscriptions/b12cd397b-e500-788j-ae53-1b0008014120/providers/Microsoft.Fabric/capacities?api-version=2023-11-01 ``` ```bash # list skus fab:/$ api -A azure subscriptions/b12cd397b-e500-788j-ae53-1b0008014120/providers/Microsoft.Fabric/skus?api-version=2023-11-01 ``` -------------------------------- ### Get and Query Shortcut Details Source: https://microsoft.github.io/fabric-cli/examples/shortcut_examples Retrieves and queries item details for shortcuts. The `-q` flag allows for JMESPath queries, and `-o` specifies the output location (Local or Lakehouse). ```bash # get JSON properties fab:/ws1.Workspace/lh1.Lakehouse$ get Files/scut.Shortcut fab:/ws1.Workspace/lh1.Lakehouse$ get Tables/ext_table.Shortcut # query using JMESPath fab:/ws1.Workspace/lh1.Lakehouse$ get Files/scut.Shortcut -q target fab:/ws1.Workspace/lh1.Lakehouse$ get Tables/ext_table.Shortcut -q . # export query result fab:/ws1.Workspace/lh1.Lakehouse$ get Files/scut.Shortcut -q target -o /tmp fab:/ws1.Workspace/lh1.Lakehouse$ get Tables/ext_table.Shortcut -q . -o /tmp ``` -------------------------------- ### Fabric CLI - Managing Connections Source: https://microsoft.github.io/fabric-cli/examples Examples for managing connections using the Fabric CLI. This section details how to handle connection configurations. ```bash # Refer to: https://microsoft.github.io/fabric-cli/examples/connection_examples.html ``` -------------------------------- ### Create a Connection Source: https://microsoft.github.io/fabric-cli/examples/connection_examples Provides examples for creating a new connection synchronously. It shows how to specify required parameters like connection type and details, and optional parameters such as gateway, description, and privacy level. ```bash # use only required params fab:/$ create .connections/conn2.Connection -P connectionDetails.type=SQL,connectionDetails.parameters.server=contoso.database.windows.net,connectionDetails.parameters.database=sales,credentialDetails.type=Basic,credentialDetails.username=,credentialDetails.password= # specify gateway fab:/$ create .connections/conn3.Connection -P gateway=MyVnetGateway.Gateway,connectionDetails.type=SQL,connectionDetails.parameters.server=contoso.database.windows.net,connectionDetails.parameters.database=sales,credentialDetails.type=Basic,credentialDetails.username=,credentialDetails.password= ``` -------------------------------- ### Getting and Querying Spark Pool Details Source: https://microsoft.github.io/fabric-cli/examples/sparkpool_examples Illustrates how to retrieve Spark pool details using the `get` command. Supports outputting to a local path or 'Lakehouse/Files' with the `-o` flag and querying with JMESPath using `-q`. ```bash # get JSON propertie fab:/ws1.Workspace/.sparkpools$ get pool1.SparkPool # export JMESPath query result fab:/ws1.Workspace/.sparkpools$ get pool1.SparkPool -q . -o /tmp ``` -------------------------------- ### Create Fabric CLI Capacity Source: https://microsoft.github.io/fabric-cli/examples/capacity_examples Provides examples for creating a capacity synchronously using the 'create' command. Optional parameters like 'sku', 'admin', 'location', 'resourceGroup', and 'subscriptionId' can be specified using '-P'. Defaults are applied if parameters are omitted. Parameter names are case-insensitive. ```bash # use default config fab:/$ create .capacities/capac2.Capacity # specify sku fab:/$ create .capacities/capac3.Capacity -P sku=F4 # inline params fab:/$ create .capacities/capac4.Capacity -P sku=F2,admin=fabcli@microsoft.com,location=westeurope,resourcegroup=rg-fab-cli,subscriptionid=b1cd297b-e573-483f-ae53-1b8a08014120 ``` -------------------------------- ### Start Spark Job Definition (SJD) with Payload Definition Source: https://microsoft.github.io/fabric-cli/examples/job_examples Starts a Spark Job Definition asynchronously, providing a detailed payload that includes command-line arguments, environment, and lakehouse artifact IDs. ```bash $ job start ws1.Workspace/sjd1.SparkJobDefinition -i { "commandLineArguments": "param01 TEST param02 1234", "environmentArtifactId": "", "defaultLakehouseArtifactId": "", "additionalLakehouseIds": [""] } ``` -------------------------------- ### Fabric CLI - Using Config Source: https://microsoft.github.io/fabric-cli/examples Examples demonstrating the use of configuration (Config) commands in the Fabric CLI. This section covers configuration management. ```bash # Refer to: https://microsoft.github.io/fabric-cli/examples/config_examples.html ``` -------------------------------- ### Create Domain in Fabric CLI Source: https://microsoft.github.io/fabric-cli/examples/domain_examples Provides examples for creating a new domain using the 'create' command. It shows basic creation, specifying a parent domain and description using '-P', and specifying only the parent domain. ```bash # using default configs fab:/$ create .domains/domain1.Domain # specify parent and description fab:/$ create .domains/domain2.Domain -P parentdomainname=domain1,description=domain 2 # specify parent fab:/$ create .domains/domain3.Domain -P parentDomainName=domain1.Domain ``` -------------------------------- ### OneLake API Examples Source: https://microsoft.github.io/fabric-cli/examples/api_examples Shows how to interact with the OneLake REST API for accessing files within a Lakehouse. Examples include retrieving content and using parameters to filter results. ```bash # get content from Lakehouse/Files section fab:/$ api -A storage ws1/lh1.Lakehouse/Files?resource=filesystem&recursive=false ``` ```bash # using parameters fab:/$ api -A storage ws1/lh1.Lakehouse/Files -P resource=filesystem,recursive=false --show_headers ``` -------------------------------- ### Fabric CLI - Managing Gateways Source: https://microsoft.github.io/fabric-cli/examples Examples for managing gateways with the Fabric CLI. This section provides guidance on gateway operations. ```bash # Refer to: https://microsoft.github.io/fabric-cli/examples/gateway_examples.html ``` -------------------------------- ### Create Gateway Source: https://microsoft.github.io/fabric-cli/examples/gateway_examples Provides examples for creating a gateway, including using only required parameters and specifying inline optional parameters. Defaults apply if optional parameters are unspecified. ```bash # use only required params fab:/$ create .gateways/conn2.Connection -P capacity=mycapacityname,virtualNetworkName=west-us-2-fabric-test-vnet,subnetName=vnet-gateway # inline params fab:/$ create .gateways/conn4.Connection -P capacity=mycapacityname,resourceGroupName=my-rg,subscriptionId=25bdf70e-..f192,virtualNetworkName=fabric-vnet-name,subnetName=fabric-subnet-name,inactivityMinutesBeforeSleep=60,numberOfMemberGateways=2, ``` -------------------------------- ### Get and Query Domain Details in Fabric CLI Source: https://microsoft.github.io/fabric-cli/examples/domain_examples Illustrates how to retrieve domain details using the 'get' command. It supports querying specific properties using JMESPath with the '-q' flag and outputting results to a local path or 'Lakehouse/Files' with the '-o' flag. ```bash # get JSON properties fab:/$ get .domains/domain1.Domain # query using JMESPath fab:/$ get .domains/domain1.Domain -q . -o /tmp ``` -------------------------------- ### Get and Query Connection Permissions Source: https://microsoft.github.io/fabric-cli/examples/connection_examples Retrieves and queries connection permissions using JMESPath. Results can be output to a local path or Lakehouse/Files. The `acl get` command fetches permissions, `-q` applies a JMESPath query, and `-o` specifies the output location. ```bash # get JSON properties fab:/$ acl get .connections/conn.Connection # query using JMESPath fab:/$ acl get .connections/conn.Connection -q [*].principal # export JMESPath query result fab:/$ acl get .connections/conn.Connection -q [*].principal -o /tmp # export to lakehouse using absolute path fab:/$ cd .connections/conn.Connection * Switched to 'conn.Connection' fab:/.connections/conn.Connection$ acl get . -q [*].principal -o /ws1.Workspace/lh1.Lakehouse/Files ``` -------------------------------- ### Getting a Fabric CLI Configuration Setting Source: https://microsoft.github.io/fabric-cli/examples/config_examples Retrieves and prints the value of a specific configuration key within the Fabric CLI. This allows users to inspect individual settings. ```bash fab:/$ config get mode ``` -------------------------------- ### Creating a Spark Pool Source: https://microsoft.github.io/fabric-cli/examples/sparkpool_examples Provides examples for creating a Spark pool, including default settings (Small, single-node) and specifying optional parameters like `nodeSize`, `autoScale.minNodeCount`, and `autoScale.maxNodeCount`. ```bash # Small single-node by default fab:/ws1.Workspace/.sparkpools$ create pool2.SparkPool # with parameters fab:/ws1.Workspace/.sparkpools$ create pool3.SparkPool -P nodesize=Medium,autoScale.minnodecount=1,autoScale.maxnodecount=3 ``` -------------------------------- ### Power BI API Examples Source: https://microsoft.github.io/fabric-cli/examples/api_examples Provides examples for interacting with the Power BI REST API using the fabric-cli. Demonstrates listing datasets within a group and listing available groups. ```bash # list datasets in a group fab:/$ api -A powerbi groups/addb15df-4af9-44f2-9b8b-c65c0b6086cd/datasets ``` ```bash # list groups fab:/$ api -A powerbi groups ``` -------------------------------- ### Fabric CLI - Managing OneLake Shortcuts Source: https://microsoft.github.io/fabric-cli/examples Examples for managing OneLake shortcuts with the Fabric CLI. This section details shortcut creation and management. ```bash # Refer to: https://microsoft.github.io/fabric-cli/examples/shortcut_examples.html ``` -------------------------------- ### Fabric CLI - Managing Items Source: https://microsoft.github.io/fabric-cli/examples Examples for managing items within the Fabric CLI. This section provides guidance on item operations. ```bash # Refer to: https://microsoft.github.io/fabric-cli/examples/item_examples.html ``` -------------------------------- ### Fabric CLI - Managing Domains Source: https://microsoft.github.io/fabric-cli/examples Examples for managing domains using the Fabric CLI. This section covers domain-related command usage. ```bash # Refer to: https://microsoft.github.io/fabric-cli/examples/domain_examples.html ``` -------------------------------- ### Fabric CLI - Managing Tables Source: https://microsoft.github.io/fabric-cli/examples Examples for managing tables using the Fabric CLI. This section covers table operations and configurations. ```bash # Refer to: https://microsoft.github.io/fabric-cli/examples/table_examples.html ``` -------------------------------- ### Fabric CLI: Authenticate with Service Principal and Federated Credential Source: https://microsoft.github.io/fabric-cli/examples/auth_examples Provides examples for authenticating with a Service Principal using a federated credential. Includes links to examples for GitHub Actions and Azure Pipelines. Tenant settings must be enabled for Service Principal authentication. ```bash # interactive mode fab:/$ auth login ? How would you like to authenticate Fabric CLI? Service principal authentication with federated credential ! Ensure tenant setting is enabled for Service Principal auth # command_line mode $ fab auth login [-u ] [--federated-token ] [--tenant ] ``` -------------------------------- ### Fabric CLI - Managing Workspaces Source: https://microsoft.github.io/fabric-cli/examples Examples for managing workspaces in the Fabric CLI. This section demonstrates workspace operations. ```bash # Refer to: https://microsoft.github.io/fabric-cli/examples/workspace_examples.html ``` -------------------------------- ### Fabric CLI - Managing Labels Source: https://microsoft.github.io/fabric-cli/examples Examples for managing labels using the Fabric CLI. This section covers label management functionalities. ```bash # Refer to: https://microsoft.github.io/fabric-cli/examples/label_examples.html ``` -------------------------------- ### Fabric CLI - Managing Capacities Source: https://microsoft.github.io/fabric-cli/examples Examples for managing capacities within the Fabric CLI. This section covers operations related to capacity management. ```bash # Refer to: https://microsoft.github.io/fabric-cli/examples/capacity_examples.html ``` -------------------------------- ### Fabric CLI - Using Auth Source: https://microsoft.github.io/fabric-cli/examples Examples for authentication (Auth) operations with the Fabric CLI. This section covers authentication methods and usage. ```bash # Refer to: https://microsoft.github.io/fabric-cli/examples/auth_examples.html ``` -------------------------------- ### Fabric CLI - Using API Source: https://microsoft.github.io/fabric-cli/examples Examples demonstrating the use of the API functionalities within the Fabric CLI. This section covers API interactions. ```bash # Refer to: https://microsoft.github.io/fabric-cli/examples/api_examples.html ``` -------------------------------- ### Fabric CLI - Managing Spark Pools Source: https://microsoft.github.io/fabric-cli/examples Examples for managing Spark pools using the Fabric CLI. This section covers Spark pool operations. ```bash # Refer to: https://microsoft.github.io/fabric-cli/examples/sparkpool_examples.html ``` -------------------------------- ### Fabric CLI - Using Desc Source: https://microsoft.github.io/fabric-cli/examples Examples for using description (Desc) functionalities within the Fabric CLI. This section covers how to generate or use descriptions. ```bash # Refer to: https://microsoft.github.io/fabric-cli/examples/desc_examples.html ``` -------------------------------- ### Fabric CLI - Managing OneLake Files and Folders Source: https://microsoft.github.io/fabric-cli/examples Examples for managing OneLake files and folders using the Fabric CLI. This section covers file and folder operations in OneLake. ```bash # Refer to: https://microsoft.github.io/fabric-cli/examples/onelake_examples.html ``` -------------------------------- ### Set and Update Item Properties Source: https://microsoft.github.io/fabric-cli/examples/item_examples Provides examples for setting and updating item properties such as 'displayName' and 'description'. It also shows how to rebind items like Reports to Semantic Models and Notebooks to Lakehouses, Environments, or Warehouses. The '-f' flag is used to force updates, and properties are case-sensitive. ```bash # rename items fab:/ws1.Workspace$ set nb2.Notebook -q displayName -i nb2ren fab:/ws1.Workspace$ set lh2.Lakehouse -q displayName -i lh2ren # set description fab:/ws1.Workspace$ set nb2ren.Notebook -q description -i "my desc" -f fab:/ws1.Workspace$ set lh2ren.Lakehouse -q description -i "my desc" -f # [report] rebind to a semantic model fab:/ws1.Workspace$ set rep1.Report -q semanticModelId -i 7b0ae03b-563d-42a2-8fd3-c655fa468dfe # [notebook] rebind or set a default lakehouse fab:/ws1.Workspace$ set nb1.Notebook -q lakehouse -i {"known_lakehouses": [{"id": "82549658-98f4-405f-be96-96c3ad75054f"}],"default_lakehouse": "82549658-98f4-405f-be96-96c3ad75054f","default_lakehouse_name": "lh1a","default_lakehouse_workspace_id": "762811e8-e364-4817-9557-f2ca363661cb"} -f # [notebook] rebind or set a default environment fab:/ws1.Workspace$ set nb1.Notebook -q environment -i {"environmentId": "fc238f0f-18de-457f-87d1-8aa0b825ae95", "workspaceId": "762811e8-e364-4817-9557-f2ca363661cb"} -f # [notebook] rebind or set a default warehouse fab:/ws1.Workspace$ set nb1.Notebook -q warehouse -i {"known_warehouses": [{"id": "16871e76-cb30-437f-a41f-2747cf145b8a", "type": "Datawarehouse"}], "default_warehouse": "16871e76-cb30-437f-a41f-2747cf145b8a"} -f ``` -------------------------------- ### Navigate Fabric CLI Capacity Source: https://microsoft.github.io/fabric-cli/examples/capacity_examples Demonstrates how to navigate to different capacity contexts within the Fabric CLI using absolute and relative paths with the 'cd' command. ```bash # use absolute path fab:/ws1.Workspace$ cd /.capacities * Switched to '.capacities' # use relative path fab:/ws1.Workspace$ cd ../.capacities/capac1.Capacity * Switched to 'capac1.Capacity' ``` -------------------------------- ### Schedule Data Pipeline Job (Cron) Source: https://microsoft.github.io/fabric-cli/examples/job_examples Schedules a data pipeline job to run at a specified cron interval. This example enables the schedule and sets start and end times. ```bash # run every 10 minutes and enable it fab:/$ job run-sch pip1.DataPipeline --type cron --interval 10 --start 2024-11-15T09:00:00 --end 2024-12-15T10:00:00 --enable ``` -------------------------------- ### Navigating Spark Pools Source: https://microsoft.github.io/fabric-cli/examples/sparkpool_examples Demonstrates how to navigate to Spark pools within a workspace using absolute and relative paths with the `cd` command. ```bash # use absolute path fab:/ws1.Workspace$ cd /ws1.Workspace/.sparkpools * Switched to '.sparkpools' # use relative path fab:/ws1.Workspace/.sparkpools$ cd pool1.SparkPool * Switched to 'pool1.SparkPool' ``` -------------------------------- ### Navigate Workspace Source: https://microsoft.github.io/fabric-cli/examples/workspace_examples Demonstrates how to navigate to different workspaces using absolute and relative paths, including the home directory shortcut. ```bash # use absolute path fab:/ws1.Workspace/lh1.Lakehouse$ cd /ws1.workspace * Switched to 'ws1.Workspace' # use relative path fab:/ws1.Workspace/lh1.Lakehouse$ cd ../../ws1.Workspace * Switched to 'ws1.Workspace' # navigate to Personal workspace fab:/$ cd My workspace.Personal * Switched to 'My workspace.Personal' fab:/$ cd ~ * Switched to 'My workspace.Personal' ``` -------------------------------- ### Get and Query External Data Share Details Source: https://microsoft.github.io/fabric-cli/examples/externaldatashare_examples Illustrates retrieving and querying external data share details using the `get` command with JMESPath queries and exporting results. ```bash # query using JMESPath fab:/ws1.Workspace$ get .externaldatashares/lh1.Lakehouse_f9e2dd00.ExternalDataShare -q . # export result fab:/ws1.Workspace$ get .externaldatashares/lh1.Lakehouse_f9e2dd00.ExternalDataShare -q . -o /tmp ``` -------------------------------- ### Get and Query Workspace Details Source: https://microsoft.github.io/fabric-cli/examples/workspace_examples Retrieves and queries workspace details using JMESPath. Results can be output to a local path or a Lakehouse path. Supports getting all JSON properties or specific queried properties. ```bash # get JSON properties fab:/$ get ws1.Workspace # query using JMESPath fab:/$ get ws1.Workspace -q sparkSettings # export JMESPath query result fab:/$ get ws1.Workspace -q sparkSettings -o /tmp ``` -------------------------------- ### Start Data Pipeline Job with Inline JSON Input Source: https://microsoft.github.io/fabric-cli/examples/job_examples Starts a data pipeline job asynchronously, providing parameters via inline JSON. This is used for setting up pipeline runs with specific parameter values. ```bash $ job start ws1.Workspace/pip1.DataPipeline -i {"parameters": {"string_param": "new_value", "int_param": 10}} ``` -------------------------------- ### List Fabric CLI Capacities Source: https://microsoft.github.io/fabric-cli/examples/capacity_examples Demonstrates how to list existing capacities and their details using the 'ls' command with the '-l' flag in the Fabric CLI. ```bash fab:/$ ls .capacities fab:/$ ls .capacities -l ``` -------------------------------- ### Get and Query Managed Private Endpoint Details Source: https://microsoft.github.io/fabric-cli/examples/managedprivateendpoint_examples Illustrates how to retrieve and query managed private endpoint details using the `get` command with JMESPath queries (`-q`) and exporting results (`-o`). ```bash # get JSON properties fab:/ws1.Workspace$ get .managedprivateendpoints/mpe1.ManagedPrivateEndpoint # export JMESPath query result fab:/ws1.Workspace$ get .managedprivateendpoints/mpe1.ManagedPrivateEndpoint -q . -o /tmp ``` -------------------------------- ### List Connections Source: https://microsoft.github.io/fabric-cli/examples/connection_examples Demonstrates how to list existing connections and their details using the 'ls' command, with and without the '-l' option for verbose output. ```bash fab:/$ ls .connections fab:/$ ls .connections -l ``` -------------------------------- ### Run Jobs Asynchronously Source: https://microsoft.github.io/fabric-cli/examples/job_examples Starts jobs without waiting for them to complete, allowing for background execution. ```bash fab:/$ job start ws1.Workspace/nb1.Notebook fab:/$ job start ws1.Workspace/pip1.DataPipeline fab:/$ job start ws1.Workspace/sjd1.SparkJobDefinition ``` -------------------------------- ### Fabric CLI API Documentation Source: https://microsoft.github.io/fabric-cli/examples/api_examples Documentation for the `fab api` command, detailing its usage for interacting with various Fabric services. Includes notes on authentication and supported audiences. ```APIDOC fab api Interact with Fabric REST API from CLI. Important: When using interactive authentication, some `api` commands may have limited functionality. If you encounter permission issues while using certain `api` commands, consider using service principal authentication as an alternative. Supported commands: `fab api -h` Audiences: - `storage`: Interacts with OneLake REST API. - `azure`: Interacts with Azure Resource Manager (ARM) REST API for Fabric capacities. - `powerbi`: Interacts with Power BI REST API. - Default (no audience specified): Interacts with the core Fabric REST API. Flags: - `-X `: Specify the HTTP method (e.g., GET, POST). - `-A `: Specify the API audience. - `-P `: Specify query parameters as key-value pairs (e.g., `resource=filesystem,recursive=false`). - `-i `: Specify a local file path for request body content (e.g., JSON or files to upload). - `--show_headers`: Display response headers. Examples: # Get Fabric workspaces fab:/$ api workspaces # Get all lakehouses in a workspace fab:/$ api -X get workspaces/762811e8-e364-4817-9557-f2ca363661cb/lakehouses --show_headers # Create an empty notebook using inline JSON fab:/$ api -X post workspaces/762811e8-e364-4817-9557-f2ca363661cb/lakehouses -i {"displayName": "nbapi"} # Upload a whl file fab:/$ api -X post workspaces/762811e8-e364-4817-9557-f2ca363661cb/environments/b12cd397b-e500-788j-ae53-1b0008014120/staging/libraries -i /tmp/mylib.whl # Get OneLake content fab:/$ api -A storage ws1/lh1.Lakehouse/Files?resource=filesystem&recursive=false # List Fabric capacities via ARM API fab:/$ api -A azure subscriptions/b12cd397b-e500-788j-ae53-1b0008014120/providers/Microsoft.Fabric/capacities?api-version=2023-11-01 # List Power BI groups fab:/$ api -A powerbi groups ``` -------------------------------- ### Listing Fabric CLI Configuration Settings Source: https://microsoft.github.io/fabric-cli/examples/config_examples Displays a list of all current configuration keys and their corresponding values for the Fabric CLI. This provides an overview of the CLI's configuration state. ```bash fab:/$ config ls ``` -------------------------------- ### Get Job Instance Status Source: https://microsoft.github.io/fabric-cli/examples/job_examples Retrieves the status of a specific job instance using its unique ID. This allows for monitoring the progress and outcome of a particular job run. ```bash fab:/$ job run-status ws1.Workspace/nb1.Notebook --id 3cf84ce6-3706-4017-a68f-e26b9ca3238c ``` -------------------------------- ### Get Gateway Permissions Source: https://microsoft.github.io/fabric-cli/examples/gateway_examples Retrieves gateway permissions in JSON format. Supports querying specific properties using JMESPath and exporting results to a local path or Fabric Lakehouse. ```bash fab:/$ acl get .gateways/gw1.Gateway ``` ```bash fab:/$ acl get .gateways/gw1.Gateway -q [*].principal ``` ```bash fab:/$ acl get .gateways/gw1.Gateway -q [*].principal -o /tmp ``` ```bash fab:/$ cd .gateways/gw1.Gateway * Switched to 'gw1.Gateway' fab:/.gateways/gw1.Gateway$ acl get . -q [*].principal -o /ws1.Workspace/lh1.Lakehouse/Files ``` -------------------------------- ### Navigate to a Connection Source: https://microsoft.github.io/fabric-cli/examples/connection_examples Demonstrates how to change the current directory to a connection using the 'cd' command. Supports both absolute and relative paths within the .connections directory. ```bash # use absolute path fab:/ws1.Workspace$ cd /.connections * Switched to '.connections' # use relative path fab:/ws1.Workspace$ cd ../.connections/conn1.Connection * Switched to 'conn1.Connection' ``` -------------------------------- ### Get Job Schedule Status Source: https://microsoft.github.io/fabric-cli/examples/job_examples Retrieves the status of a scheduled job using the `fab:/$ job run-status` command, requiring the job ID (`--id`) and the `--schedule` flag. ```bash fab:/$ job run-status ws1.Workspace/nb1.Notebook --id 2cf34ce6-3706-4347-a68f-e26b9ca3567n --schedule ``` -------------------------------- ### Get Workspace Permission Details Source: https://microsoft.github.io/fabric-cli/examples/acl_examples Retrieves and queries workspace permissions. Use `-q` with JMESPath for querying and `-o` to output results to a local path or Lakehouse. Supports relative paths for output. ```bash # get JSON properties fab:/$ acl get ws1.Workspace # query using JMESPath fab:/$ acl get ws1.Workspace -q [*].principal # export JMESPath query result fab:/$ acl get ws1.Workspace -q [*].principal -o /tmp # export to Lakehouse using relative path fab:/$ cd ws1.Workspace * Switched to 'ws1.Workspace' fab:/ws1.Workspace$ acl get . -q [*].principal -o lh1.Lakehouse/Files ``` -------------------------------- ### List Gateways Source: https://microsoft.github.io/fabric-cli/examples/gateway_examples Demonstrates how to list existing gateways and their details using the 'ls' command with the '-l' option. ```bash fab:/$ ls .gateways fab:/$ ls .gateways -l ``` -------------------------------- ### Get Item Permission Details Source: https://microsoft.github.io/fabric-cli/examples/acl_examples Retrieves and queries item permissions. Use `-q` with JMESPath for querying and `-o` to output results to a local path or Lakehouse. Supports absolute paths for output. ```bash # get JSON properties fab:/$ acl get ws1.Workspace/lh1.Lakehouse # query using JMESPath fab:/$ acl get ws1.Workspace/lh1.Lakehouse -q [*].principal # export JSON properties fab:/$ acl get ws1.Workspace/lh1.Lakehouse -o /tmp # export to Lakehouse using absolute path fab:/$ acl get ws1.Workspace/lh1.Lakehouse -o /ws1.Workspace/lh1.Lakehouse/Files ``` -------------------------------- ### Create Connection Source: https://microsoft.github.io/fabric-cli/examples/connection_examples Creates a new connection with specified parameters. If connectionDetails.creationMethod is not provided, it defaults to the first matching method based on parameters. connectionDetails.connectionEncryption defaults to Any, trying Encrypted first and then NotEncrypted. ```bash fab:/$ create .connections/conn4.Connection -P privacyLevel=Private,connectionDetails.creationMethod=SQL,gatewayId=852aee7c-d056-48dc-891f-9d7110a01b88,connectionDetails.type=SQL,connectionDetails.parameters.server=contoso.database.windows.net,connectionDetails.parameters.database=sales,credentialDetails.type=Basic,credentialDetails.username=,credentialDetails.password=,credentialDetails.connectionEncryption=NotEncrypted,credentialDetails.skipTestConnection=False ``` -------------------------------- ### Schedule Data Pipeline with Custom Input Source: https://microsoft.github.io/fabric-cli/examples/job_examples Sets up a data pipeline schedule using a JSON configuration that includes enabling the schedule, defining start and end times, time zone, and cron interval. ```bash # set up pipeline schedule with custom input fab:/$ job run-sch pip1.DataPipeline -i {'enabled': true, 'configuration': {'startDateTime': '2024-04-28T00:00:00', 'endDateTime': '2024-04-30T23:59:00', 'localTimeZoneId': 'Central Standard Time', 'type': 'Cron', 'interval': 10}} ``` -------------------------------- ### Get OneLake Permissions Details for Lakehouse Source: https://microsoft.github.io/fabric-cli/examples/acl_examples Retrieves and queries OneLake RBAC permissions. Use `-q` with JMESPath for querying and `-o` to output results to a local path or Lakehouse. Supports exporting JMESPath query results. ```bash # get JSON properties fab:/$ acl get ws1.Workspace/lh1.Lakehouse/Files # query using JMESPath fab:/$ acl get ws1.Workspace/lh1.Lakehouse/Files -q [].members # export JMESPath query result fab:/$ acl get ws1.Workspace/lh1.Lakehouse/Files -q [].members -o /tmp ``` -------------------------------- ### Get and Query Item Details Source: https://microsoft.github.io/fabric-cli/examples/item_examples Retrieves and queries item details using JMESPath. Results can be output to a local path or 'Lakehouse/Files' using the -o flag. The -v flag shows all JSON properties, and the -f flag can be used to exclude the sensitivity label. ```bash # get JSON properties fab:/ws1.Workspace$ get lh1.Lakehouse # get all JSON properties fab:/ws1.Workspace$ get rep1.Report -v # query using JMESPath fab:/ws1.Workspace$ get lh1.Lakehouse -q properties.sqlEndpointProperties # export query result fab:/ws1.Workspace$ get lh1.Lakehouse -q properties.sqlEndpointProperties -o /tmp ``` -------------------------------- ### Listing Spark Pools Source: https://microsoft.github.io/fabric-cli/examples/sparkpool_examples Demonstrates listing existing Spark pools and their details using the `ls` command, with options for JSON properties and JMESPath queries. ```bash # get JSON properties fab:/ws1.Workspace/.sparkpools$ ls # query using JMESPath fab:/ws1.Workspace/.sparkpools$ ls -l ``` -------------------------------- ### Install ms-fabric-cli Source: https://microsoft.github.io/fabric-cli/index Installs the latest version of the Microsoft Fabric CLI (fab) using pip. This command is compatible with Windows, macOS, and Linux. To upgrade an existing installation, use the --upgrade flag. ```bash pip install ms-fabric-cli ``` -------------------------------- ### Run Notebook Job with Inline Configuration and Parameters Source: https://microsoft.github.io/fabric-cli/examples/job_examples Runs a notebook job synchronously, providing both inline configuration and specific parameters. This allows for dynamic adjustment of job settings and input values. ```bash fab:/$ job run ws1.Workspace/nb1.Notebook -P string_param:string=new_value -C {"environment": { "id": "", "name": "" }} ``` -------------------------------- ### Fabric CLI: Authenticate with User Credentials Source: https://microsoft.github.io/fabric-cli/examples/auth_examples Demonstrates how to log in to a Fabric account using interactive login with user credentials. The CLI handles the refresh token management. ```bash # interactive mode fab:/$ auth login ? How would you like to authenticate Fabric CLI? Interactive with a web browser # command_line mode $ fab auth login ? How would you like to authenticate Fabric CLI? Interactive with a web browser ``` -------------------------------- ### Fabric CLI - Managing Jobs Source: https://microsoft.github.io/fabric-cli/examples Examples for managing jobs with the Fabric CLI. This section details job-related command usage. ```bash # Refer to: https://microsoft.github.io/fabric-cli/examples/job_examples.html ```