Skip to content

docs(DatasetRefresh): create sample of dataset refresh using API command#175

Open
may-hartov wants to merge 2 commits intomicrosoft:mainfrom
may-hartov:dev/mahartov/dataset_Refresh_using_api_command
Open

docs(DatasetRefresh): create sample of dataset refresh using API command#175
may-hartov wants to merge 2 commits intomicrosoft:mainfrom
may-hartov:dev/mahartov/dataset_Refresh_using_api_command

Conversation

@may-hartov
Copy link
Collaborator

@may-hartov may-hartov commented Feb 16, 2026

This pull request introduces comprehensive documentation and examples for triggering and monitoring Power BI dataset refresh operations using the Fabric CLI API command. The main change is the addition of a new guide with PowerShell and Bash scripts, along with cross-linking and navigation updates to make the refresh example easily discoverable.

Dataset Refresh Documentation and Examples:

  • Added a new guide refresh_dataset_example.md with detailed instructions and scripts (PowerShell and Bash) for triggering and polling dataset refresh status using Power BI REST API endpoints via the Fabric CLI. The guide covers extracting polling URLs from response headers and handling refresh completion states.
  • Updated item_examples.md to reference the new dataset refresh example, making it easier for users to find relevant API usage instructions.

dataset refresh Script:

  • Triggers a dataset refresh - Uses the Power BI REST API to initiate an on-demand refresh operation for a specified dataset in a workspace
  • Extracts the polling endpoint - Parses the API response headers (Location or RequestId) to obtain the status monitoring URL
  • Continuously monitors progress - Polls the refresh status at regular intervals until the operation completes, fails, or times out
  • Reports the outcome - Displays real-time status updates and exits with success (Completed) or failure (Failed/Cancelled/TimedOut/Disabled) codes

Documentation Navigation Improvements:

  • Added the new "Dataset Refresh Example" page to the mkdocs.yml navigation under Item Management, improving discoverability in the docs sidebar.

Release Notes:

  • Created a release note documenting the addition of the dataset refresh API command example.

Doc layout:
image
image

@@ -0,0 +1,6 @@
kind: docs
body: Created refresh dataset using API command example
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

semantic model :)

fab stop ws1.Workspace/mir1.MirroredDatabase -f
```

### Dataset Refresh
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Semantic Model

- Workspace Examples: examples/workspace_examples.md
- Item Management:
- Item Examples: examples/item_examples.md
- Dataset Refresh Example: examples/refresh_dataset_example.md
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can it be a child of api's examples?

Comment on lines +5 to +23
## APIs Used

This script demonstrates two Power BI REST API endpoints:

### Refresh Dataset In Group

**[Refresh Dataset In Group](https://learn.microsoft.com/rest/api/power-bi/datasets/refresh-dataset-in-group)** - Triggers an on-demand dataset refresh operation

- Method: `POST`
- Endpoint: `groups/{workspaceId}/datasets/{datasetId}/refreshes`

### Get Refresh Execution Details In Group

**[Get Refresh Execution Details In Group](https://learn.microsoft.com/rest/api/power-bi/datasets/get-refresh-execution-details-in-group)** - Retrieves the status of a specific refresh operation

- Method: `GET`
- Endpoint: `groups/{workspaceId}/datasets/{datasetId}/refreshes/{refreshId}`

The POST response includes a `Location` header containing the polling URL, or a `RequestId` header that can be used to construct the polling endpoint for the GET request.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

although it adds some background, i think it is redundant here.

i would suggest to keep this doc concise so it speak to our cli end users.

i would expect of something like

`to refresh semantic model, you can use our api command as follows:

Run refresh on demand

fab api -A powerbi -X post "groups/$WORKSPACE_ID/datasets/$SEMANTIC_MODEL_ID/refreshes"

where $SEMANTIC_MODEL_ID and WORKSPACE_ID are set to ...

Run refresh on demand with params

you can also provide additional params to the refresh job, based on the supported payload documented in here [link to api page], as follows:

REQUEST_BODY='{"retryCount":"1","timeout":"00:20:00"}'

fab api -A powerbi -X post "groups/$WORKSPACE_ID/datasets/$SEMANTIC_MODEL_ID/refreshes" --show_headers -i "$REQUEST_BODY"

Run refresh with polling for completion

REFRESH_RESPONSE=$(fab api -A powerbi -X post "groups/$WORKSPACE_ID/datasets/$SEMANTIC_MODEL_ID/refreshes")

STATUS_CODE=$(echo "$REFRESH_RESPONSE" | jq -r '.status_code // empty')

if [ "$STATUS_CODE" != "202" ]; then
    exit 1
fi

POLLING_ENDPOINT=""
LOCATION=$(echo "$REFRESH_RESPONSE" | jq -r '.headers.Location // empty')
if [ -n "$LOCATION" ]; then
    POLLING_ENDPOINT=$(echo "$LOCATION" | sed -n 's|.*https\?://[^/]*/v1\.0/myorg/\(.*\)|\1|p' | xargs)
fi

if [ -z "$POLLING_ENDPOINT" ]; then
    REFRESH_REQUEST_ID=$(echo "$REFRESH_RESPONSE" | jq -r '.headers.RequestId // empty')
    if [ -n "$REFRESH_REQUEST_ID" ]; then
         POLLING_ENDPOINT="groups/$WORKSPACE_ID/datasets/$SEMANTIC_MODEL_ID/refreshes/$REFRESH_REQUEST_ID"
    fi
fi

if [ -z "$POLLING_ENDPOINT" ]; then
    exit 1
fi

while true; do
    sleep "$POLLING_INTERVAL"
    
    STATUS_RESPONSE=$(fab api -A powerbi "$POLLING_ENDPOINT" --show_headers)
    
    GET_STATUS_CODE=$(echo "$STATUS_RESPONSE" | jq -r '.status_code // empty')
    
    if [ "$GET_STATUS_CODE" != "200" ] && [ "$GET_STATUS_CODE" != "202" ]; then
        echo "$STATUS_RESPONSE"
    fi
    
    EXTENDED_STATUS=$(echo "$STATUS_RESPONSE" | jq -r '.text.extendedStatus // empty')
    if [ -n "$EXTENDED_STATUS" ]; then
        STATUS="$EXTENDED_STATUS"
    else
        STATUS=$(echo "$STATUS_RESPONSE" | jq -r '.text.status // empty')
    fi
    
    
    case "$STATUS" in
        "Completed")
            exit 0
            ;;
        "Failed"|"Cancelled"|"Disabled"|"TimedOut")
            echo "$STATUS_RESPONSE"
            exit 1
            ;;
        "NotStarted"|"InProgress"|"Unknown")
            # Continue polling
            ;;
        *)
            echo "$STATUS_RESPONSE"
            exit 1
            ;;
    esac
done

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.

2 participants