2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Log Analytics ワークスペースでサポートされた Granular RBAC (きめ細かい RBAC) を PowerShell で一括設定

Last updated at Posted at 2025-07-15

はじめに

こんにちは。 @yama-s です。
本記事では以下について取り扱います。

  • Granular RBAC (きめ細かい RBAC)

Granular RBAC とは

Granular RBAC(きめ細かなロールベース アクセス コントロール)は、Log Analytics ワークスペース内のデータに対して、テーブル単位でアクセス権を設定できる機能です。

従来のワークスペース単位のアクセス制御に加え、特定のテーブルや条件式に基づいた特定のフィールドの値のみを閲覧可能にすることで、より柔軟なセキュリティ管理が可能になります。

これにより最小権限の原則を実現しやすくなり、組織内のデータ保護が強化されます。

参考:https://learn.microsoft.com/en-us/azure/azure-monitor/logs/granular-rbac-log-analytics

設定のわかりやすい手順は @hisnakad さんの以下記事でもご紹介されています。

動作イメージ

本記事では動作イメージをお伝えすることを目的として大まかな流れを記載します。
まず必要なリソースおよび設定を準備します。

  • カスタムロールを作成
  • カスタムロールをユーザーに割り当て
    (Log Analytics ワークスペースの IAM 設定)
  • 条件式を設定

テーブル単位で制御する場合
(ここでの条件の内容:「AzureActivity」テーブルのみを表示)
image.png

フィールドの値で制御する場合
(ここでの条件の内容:「AzureActivity」テーブルの「Caller」列で「admin」から始まるものを表示)
image.png

設定後、以下に示す通り特定のワークスペースかつ特定のテーブルまたは条件式に基づいた対象フィールドの特定の値のみが表示されていることが確認できます。

本設定を入れていないユーザーの例:
AzureActivity テーブルも DeviceEvents テーブルも閲覧可能な状態です。
image.png
image.png

本設定を入れたユーザーの例:
AzureActivity テーブルのみ閲覧可能な状態です。
image.png
image.png

(参考) PowerShell スクリプト

注意事項
本記事は個人の検証目的で作成したものです。ご利用の際は、環境に応じて適宜ご調整ください。
スクリプトのご利用により発生したいかなる問題についても、責任を負いかねます。あらかじめご了承ください。
ご意見・ご指摘などありましたら、お気軽にコメントいただけると嬉しいです!

ロールの割り当てについてのスクリプトサンプルです。

ポイント

  • scope はリソースグループ等ではなく、対象 LogAnalytics ワークスペースを指定する
スクリプトサンプル
# パラメータ定義
$subscriptionId = "<サブスクリプション ID>"
$resourceGroup = "<リソースグループ名>"
$workspaceName = "<LogAnalytics ワークスペース名>"
$roleDefinitionId = "<ロール定義 ID>"
$userObjectId = "<割り当て対象ユーザーの ID>"
$description = "<任意の説明>"
$condition = "((!(ActionMatches{'Microsoft.OperationalInsights/workspaces/tables/data/read'})) OR (@Resource[Microsoft.OperationalInsights/workspaces/tables:name] ForAllOfAnyValues:StringEquals {'<マッチさせる文字列>'}))"
$conditionVersion = "2.0"

# スコープ
$scope = "/subscriptions/$subscriptionId/resourceGroups/$resourceGroup/providers/Microsoft.OperationalInsights/workspaces/$workspaceName"

# ロール割り当ての作成
New-AzRoleAssignment `
    -ObjectId $userObjectId `
    -Scope $scope `
    -RoleDefinitionId $roleDefinitionId `
    -Description $description `
    -Condition $condition `
    -ConditionVersion $conditionVersion
(実際に値を入れた例)
# パラメータ定義
$subscriptionId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx62eb"
$resourceGroup = "resourcegroup1"
$workspaceName = "LA-tenantA"
$roleDefinitionId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxc51f"
$userObjectId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxa542"
$description = "for Granular RBAC"
$condition = "((!(ActionMatches{'Microsoft.OperationalInsights/workspaces/tables/data/read'})) OR (@Resource[Microsoft.OperationalInsights/workspaces/tables:name] ForAllOfAnyValues:StringEquals {'AzureActivity'}))"
$conditionVersion = "2.0"

# スコープ
$scope = "/subscriptions/$subscriptionId/resourceGroups/$resourceGroup/providers/Microsoft.OperationalInsights/workspaces/$workspaceName"

# ロール割り当ての作成
New-AzRoleAssignment `
    -ObjectId $userObjectId `
    -Scope $scope `
    -RoleDefinitionId $roleDefinitionId `
    -Description $description `
    -Condition $condition `
    -ConditionVersion $conditionVersion

まとめ

ご興味ありましたらぜひ Granular RBAC を試してみてください。

記事をご覧いただきありがとうございました。
何か少しでも参考にしていただける箇所がありましたら幸いです。


参考資料:

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?