使用服務主體進行自動化 (機器翻譯)

服務主體是您在租使用者內建立的 Microsoft Entra 應用程式資源,可執行自動資源和服務等級作業。 它們是具有應用程式識別碼和密碼或憑證的唯一使用者身分識別 類型 。 服務主體只有執行指派其角色和許可權所定義之工作所需的許可權。

在 Analysis Services 中,服務主體會與 Azure 自動化、PowerShell 自動模式、自訂用戶端應用程式和 Web 應用程式搭配使用,以自動化一般工作。 例如,布建伺服器、部署模型、資料重新整理、相應增加/減少和暫停/繼續都可以使用服務主體來自動化。 許可權會透過角色成員資格指派給服務主體,就像一般 Microsoft Entra UPN 帳戶一樣。

Analysis Services「不支援」使用服務主體的受控識別所執行的作業。 若要深入了解,請參閱適用於 Azure 資源的受控識別支援 Microsoft Entra 驗證的 Azure 服務

建立服務主體

服務主體可以在Azure 入口網站或使用 PowerShell 來建立。 若要深入了解,請參閱:

建立服務主體 - Azure 入口網站
建立服務主體 - PowerShell

將認證和憑證資產儲存在 Azure 自動化

服務主體認證和憑證可以安全地儲存在 Runbook 作業Azure 自動化中。 若要深入了解,請參閱:

Azure 自動化中的認證資產
Azure 自動化中的憑證資產

將服務主體新增至伺服器管理員角色

您必須先將它新增至伺服器管理員角色,才能使用 Analysis Services 伺服器管理作業的服務主體。 必須「直接」將服務主體新增至伺服器管理員角色。 不支援將服務主體新增至安全性群組,然後將該安全性群組新增至伺服器管理員角色。 若要深入瞭解,請參閱 將服務主體新增至伺服器管理員角色

連接字串中的服務主體

服務主體 appID 和密碼或憑證可以在與 UPN 相同的連接字串中使用。

PowerShell

注意

建議您使用 Azure Az PowerShell 模組來與 Azure 互動。 請參閱安裝 Azure PowerShell 以開始使用。 若要了解如何移轉至 Az PowerShell 模組,請參閱將 Azure PowerShell 從 AzureRM 移轉至 Az

使用 Az.AnalysisServices 模組

搭配 Az.AnalysisServices 模組使用服務主體進行資源管理作業 時,請使用 Connect-AzAccount Cmdlet。

在下列範例中,appID 和密碼可用來執行控制平面作業,以便同步處理至唯讀複本並相應增加/放大:

Param (
        [Parameter(Mandatory=$true)] [String] $AppId,
        [Parameter(Mandatory=$true)] [String] $PlainPWord,
        [Parameter(Mandatory=$true)] [String] $TenantId
       )
$PWord = ConvertTo-SecureString -String $PlainPWord -AsPlainText -Force
$Credential = New-Object -TypeName "System.Management.Automation.PSCredential" -ArgumentList $AppId, $PWord

# Connect using Az module
Connect-AzAccount -Credential $Credential -SubscriptionId "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx"

# Synchronize a database for query scale out
Sync-AzAnalysisServicesInstance -Instance "asazure://westus.asazure.windows.net/testsvr" -Database "testdb"

# Scale up the server to an S1, set 2 read-only replicas, and remove the primary from the query pool. The new replicas will hydrate from the synchronized data.
Set-AzAnalysisServicesServer -Name "testsvr" -ResourceGroupName "testRG" -Sku "S1" -ReadonlyReplicaCount 2 -DefaultConnectionMode Readonly

使用 SQLServer 模組

在下列範例中,appID 和密碼可用來執行模型資料庫重新整理作業:

Param (
        [Parameter(Mandatory=$true)] [String] $AppId,
        [Parameter(Mandatory=$true)] [String] $PlainPWord,
        [Parameter(Mandatory=$true)] [String] $TenantId
       )
$PWord = ConvertTo-SecureString -String $PlainPWord -AsPlainText -Force

$Credential = New-Object -TypeName "System.Management.Automation.PSCredential" -ArgumentList $AppId, $PWord

Invoke-ProcessTable -Server "asazure://westcentralus.asazure.windows.net/myserver" -TableName "MyTable" -Database "MyDb" -RefreshType "Full" -ServicePrincipal -ApplicationId $AppId -TenantId $TenantId -Credential $Credential

AMO 和 ADOMD

與用戶端應用程式和 Web 應用程式連線時, 來自 NuGet 的 AMO 和 ADOMD 用戶端程式庫 15.0.2 版和更新版本的可安裝套件會使用下列語法,在 連接字串 中支援服務主體: app:AppID 和密碼或 cert:thumbprint

在下列範例中, appIDpassword 是用來執行模型資料庫重新整理作業:

string appId = "xxx";
string authKey = "yyy";
string connString = $"Provider=MSOLAP;Data Source=asazure://westus.asazure.windows.net/<servername>;User ID=app:{appId};Password={authKey};";
Server server = new Server();
server.Connect(connString);
Database db = server.Databases.FindByName("adventureworks");
Table tbl = db.Model.Tables.Find("DimDate");
tbl.RequestRefresh(RefreshType.Full);
db.Model.SaveChanges();

下一步

使用 Azure PowerShell 登入
使用 Logic Apps 重新整理
使用 Azure 自動化重新整理
將服務主體新增至伺服器管理員角色
使用服務主體將 Power BI 進階版工作區和資料集工作自動化