設定語意模型向外延展

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

在 Power BI 服務 中啟用向外延展

若要在 Power BI 服務 中啟用語意模型的向外延展,請遵循下列步驟:

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

  2. 選取語意模型的 更多選項...)。

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

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

  5. 啟用 查詢向外 延展,然後選取 [ 套用]。

    A screenshot showing how to enable scale out in Power BI service.

使用資料集 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
        }
     }

停用語意模型向外延展

若要停用語意模型向外延展,請將 設定 maxReadOnlyReplicas0

###
# 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
        }
     }