共用方式為


設定語意模型擴增

您可以在 Power BI 服務中啟用擴增,或使用 Power BI 資料集 REST API。 設定語意模型之前,請閱讀 Power BI 語意模型擴增概觀。

在 Power BI 服務中啟用擴增

若要在 Power BI 服務中啟用語意模型擴增,請遵循下列步驟:

  1. 在 Power BI 服務中,使用您想要啟用擴增的語意模型開啟工作區。

  2. 選取語意模型的 [更多選項] (...)

  3. 從功能表中,選取 [設定]

  4. 在設定的頁面中,如果未啟用,請啟用 [大型語意模型儲存格式]

  5. 啟用 [查詢擴增],然後選取 [套用]

    顯示如何在 Power BI 服務中啟用擴增的螢幕擷取畫面。

使用資料集 REST API 啟用擴增

本節說明如何使用 Power BI 資料集 REST API 來設定語意模型擴增。

取得 datasetId

若要取得 datasetId,請使用 Get-PowerBIDataset。 您必須指定 workspaceId 和語意模型名稱。

Login-PowerBI | Out-Null

$workspaceId = '<enter workspaceId>'

$datasetId = Get-PowerBIDataset -WorkspaceId $workspaceId `
    | Where{$_.Name -match "<enter semantic model name>"} `
    | Select-Object -ExpandProperty Id -First 1 `
    | ForEach-Object {$_.Guid}

Write-Host
Write-Host "Workspace Id: $workspaceId"
Write-Host "Dataset Id: $datasetId"

取得目前的擴增設定

設定語意模型擴增前,請先判斷目前的設定。

###
# Get current scale-out configuration
###
Login-PowerBI | Out-Null

$workspaceId = '<enter workspaceId>'

$datasetId = Get-PowerBIDataset -WorkspaceId $workspaceId `
    | Where{$_.Name -match "<enter semantic model name>"} `
    | Select-Object -ExpandProperty Id -First 1 `
    | ForEach-Object {$_.Guid}

$response = Invoke-PowerBIRestMethod -Url "groups/$workspaceId/datasets/$datasetId" -Method Get | ConvertFrom-Json

$response.queryScaleOutSettings | Format-List

if ($response.queryScaleOutSettings.maxReadOnlyReplicas -eq -1 `
    -or $response.queryScaleOutSettings.maxReadOnlyReplicas -gt 0)
{
    Write-Host "Semantic model scale-out is enabled."
}
else
{
    Write-Host "Semantic model scale-out is disabled."
}

啟用設定語意模型擴增

若要啟用語意模型擴增,請將 maxReadOnlyReplicas 設定為 -1,或任何非 0 值。 -1 值可讓 Power BI 建立與 Power BI 容量所支援的唯讀複本數目一樣多。 您也可以將複本計數明確設定為小於容量上限的值。 建議將 maxReadOnlyReplicas 設定為 -1

###
# Enable scale-out
###
Login-PowerBI | Out-Null

$workspaceId = '<enter workspaceId>'

$datasetId = Get-PowerBIDataset -WorkspaceId $workspaceId `
    | Where{$_.Name -match "<enter semantic model name>"} `
    | Select-Object -ExpandProperty Id -First 1 `
    | ForEach-Object {$_.Guid}

Invoke-PowerBIRestMethod -Url "groups/$workspaceId/datasets/$datasetId" `
    -Method Patch -Body '{ "queryScaleOutSettings": { "maxReadOnlyReplicas": -1 }}'

Invoke-PowerBIRestMethod -Url "groups/$workspaceId/datasets/$datasetId" -Method Get `
    | ConvertFrom-Json | Select-Object -ExpandProperty queryScaleOutSettings `
    | ForEach { 
        if($_.maxReadOnlyReplicas -eq -1)
        { 
            Write-Host "Success! Semantic model scale-out has been enabled."
        } else
        {
            Write-Host "Something went wrong! Semantic model scale-out is still disabled." -ForegroundColor Red
        }
     }

停用語意模型擴增

若要停用語意模型擴增,請將 maxReadOnlyReplicas 設定為 0

###
# Disable scale-out
###
Login-PowerBI | Out-Null

$workspaceId = '<enter workspaceId>'

$datasetId = Get-PowerBIDataset -WorkspaceId $workspaceId `
    | Where{$_.Name -match "<enter semantic model name>"} `
    | Select-Object -ExpandProperty Id -First 1 `
    | ForEach-Object {$_.Guid}

Invoke-PowerBIRestMethod -Url "groups/$workspaceId/datasets/$datasetId" `
    -Method Patch -Body '{ "queryScaleOutSettings": { "maxReadOnlyReplicas": 0 }}'

Invoke-PowerBIRestMethod -Url "groups/$workspaceId/datasets/$datasetId" -Method Get `
    | ConvertFrom-Json | Select-Object -ExpandProperty queryScaleOutSettings `
    | ForEach { 
        if($_.maxReadOnlyReplicas -eq 0)
        { 
            Write-Host "Success! Semantic model scale-out has been disabled."
        } else
        {
            Write-Host "Something went wrong! Semantic model scale-out is still enabled." -ForegroundColor Red
        }
     }