サービス プリンシパルによる自動化

サービス プリンシパルは、リソースおよびサービス レベルの無人操作を実行する目的でテナント内で作成する Microsoft Entra アプリケーション リソースです。 アプリケーション ID とパスワードまたは証明書が与えられた、独自のユーザー ID です。 サービス プリンシパルには、割り当てられたロールとアクセス許可によって定義されるタスクを実行するために必要な権限のみが与えられます。

Analysis Services では、サービス プリンシパルは Azure Automation、PowerShell 無人モード、カスタム クライアント アプリケーション、Web アプリと共に使用し、共通タスクを自動化します。 たとえば、サーバーのプロビジョニング、モデルのデプロイ、データ更新、拡大縮小、一時停止/再開をすべて、サービス プリンシパルを利用することで自動化できます。 アクセス許可は、通常の Microsoft Entra UPN アカウントとほぼ同じように、ロール メンバーシップを介してサービス プリンシパルに割り当てられます。

Analysis Services では、サービス プリンシパルを使用してマネージド ID によって実行される操作は "サポートされていません"。 詳細については、Azure リソースのマネージド ID に関するページMicrosoft Entra 認証をサポートする Azure サービスに関するページを参照してください。

サービス プリンシパルの作成

サービス プリンシパルは Azure Portal で作成するか、PowerShell を利用して作成できます。 詳細については、以下をご覧ください。

サービス プリンシパルを作成する - Azure Portal
サービス プリンシパルを作成する - PowerShell

Azure Automation に資格情報と証明書資産を保存する

Runbook 操作のために、サービス プリンシパルの資格情報と証明書を Azure Automation に安全に格納できます。 詳細については、以下をご覧ください。

Azure Automation の資格情報資産
Azure Automation の証明書資産

サービス プリンシパルをサーバー管理者ロールに追加する

Analysis Services サーバー管理操作のためにサービス プリンシパルを使用するには、最初にサービス プリンシパルをサーバー管理者ロールに追加する必要があります。 サービス プリンシパルは、サーバー管理者ロールに "直接" 追加する必要があります。 サービス プリンシパルをセキュリティ グループに追加してから、そのセキュリティ グループをサーバー管理者ロールに追加することはサポートされていません。 詳細については、「サーバー管理者ロールへのサービス プリンシパルの追加」を参照してください。

接続文字列のサービス プリンシパル

サービス プリンシパル appID とパスワードまたは証明書は、UPN とほぼ同じように接続文字列で使用できます。

PowerShell

注意

Azure を操作するには、Azure Az PowerShell モジュールを使用することをお勧めします。 作業を開始するには、Azure PowerShell のインストールに関する記事を参照してください。 Az PowerShell モジュールに移行する方法については、「AzureRM から Az への Azure PowerShell の移行」を参照してください。

Az.AnalysisServices モジュールの使用

Az.AnalysisServices モジュールによるリソース管理操作でサービス プリンシパルを使用するときは、Connect-AzAccount コマンドレットを使用します。

次の例では、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 アプリと接続するとき、AMO と ADOMD のクライアント ライブラリ バージョン 15.0.2 以降の、NuGet からインストールできるパッケージでは、接続文字列にサービス プリンシパルを指定できます。構文 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 Automation を使用した更新
サーバー管理者ロールへのサービス プリンシパルの追加
サービス プリンシパルを使用した Power BI Premium ワークスペースとデータセットのタスクの自動化