docs(DatasetRefresh): create sample of dataset refresh using API command#175
docs(DatasetRefresh): create sample of dataset refresh using API command#175may-hartov wants to merge 2 commits intomicrosoft:mainfrom
Conversation
| @@ -0,0 +1,6 @@ | |||
| kind: docs | |||
| body: Created refresh dataset using API command example | |||
| fab stop ws1.Workspace/mir1.MirroredDatabase -f | ||
| ``` | ||
|
|
||
| ### Dataset Refresh |
| - Workspace Examples: examples/workspace_examples.md | ||
| - Item Management: | ||
| - Item Examples: examples/item_examples.md | ||
| - Dataset Refresh Example: examples/refresh_dataset_example.md |
There was a problem hiding this comment.
can it be a child of api's examples?
| ## 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. |
There was a problem hiding this comment.
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
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:
refresh_dataset_example.mdwith 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.item_examples.mdto reference the new dataset refresh example, making it easier for users to find relevant API usage instructions.dataset refresh Script:
Documentation Navigation Improvements:
mkdocs.ymlnavigation under Item Management, improving discoverability in the docs sidebar.Release Notes:
Doc layout:

