> For the complete documentation index, see [llms.txt](https://docs.realmjoin.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.realmjoin.com/ja/zi-dong-hua/connecting-azure-automation/azure-ad-roles-and-permissions.md). Agents can also search and read this documentation through its [MCP server](https://docs.realmjoin.com/~gitbook/mcp).

# Runbook 実行要件

この wiki ページでは、runbook を実行できるようにするために必要な要件と（システム レベルの）アクセス許可について説明します。

## PowerShell モジュール

{% hint style="info" %}
PowerShell モジュール セクションは、次に基づいて自動的に更新されます: [公開リポジトリ](https://github.com/realmjoin/realmjoin-runbooks).
{% endhint %}

で利用可能な共有 runbook [GitHub](https://github.com/realmjoin/realmjoin-runbooks) 次の Windows PowerShell モジュールを想定/使用します:

| モジュール                            | runbook における最小バージョン |
| -------------------------------- | ------------------- |
| `Az.Accounts`                    | 5.5.2               |
| `Az.Compute`                     | 11.8.0              |
| `Az.DesktopVirtualization`       | 6.0.0               |
| `Az.ManagementPartner`           | 0.8.0               |
| `Az.Storage`                     | 9.7.2               |
| `ExchangeOnlineManagement`       | 3.9.2               |
| `Microsoft.Graph.Authentication` | 2.41.2              |
| `MicrosoftTeams`                 | 7.9.0               |
| `PnP.PowerShell`                 | 3.4.1               |
| `RealmJoin.RunbookHelper`        | 0.8.10              |

RealmJoin Portal は、runbook 内から参照された場合、これらのモジュールを自動的にインポートしてインストールします。このインポートでは、モジュールに指定された最小バージョンも尊重されます。

## アクセス許可

{% hint style="info" %}
権限セクションは、次に基づいて自動的に更新されます: [公開リポジトリ](https://github.com/realmjoin/realmjoin-runbooks).
{% endhint %}

RealmJoin の共有 runbook は、Azure Automation の [システム割り当てのマネージド ID](https://learn.microsoft.com/en-us/azure/automation/enable-managed-identity-for-automation) Entra ID、MS Graph API などと連携するために使用します。

以下のロールと権限の一覧により、共有リポジトリで現在利用可能なすべての runbook を使用できるようになります。

これらのロール/権限を減らすことは推奨されません。runbook はこの権限セットに対してのみテストされているためです。ロール/権限セットを減らすと、一部の runbook は動作しなくなります。

### Entra ID ロール

次の Entra ID ロールをマネージド ID に割り当ててください

* アプリケーション開発者
* クラウド デバイス管理者
* Exchange Administrator
* Intune 管理者
* Teams 管理者
* ユーザー管理者

### Graph API のアクセス許可

次の Graph API のアクセス許可をマネージド ID に付与してください

* `Application.ReadWrite.All`
* `Application.ReadWrite.OwnedBy`
* `AppRoleAssignment.ReadWrite.All`
* `AuditLog.Read.All`
* `BitlockerKey.Read.All`
* `Channel.ReadBasic.All`
* `ChannelMember.ReadWrite.All`
* `CloudPC.ReadWrite.All`
* `Device.ReadWrite.All`
* `DeviceLocalCredential.Read.All`
* `DeviceManagementApps.ReadWrite.All`
* `DeviceManagementConfiguration.ReadWrite.All`
* `DeviceManagementManagedDevices.PrivilegedOperations.All`
* `DeviceManagementManagedDevices.ReadWrite.All`
* `DeviceManagementServiceConfig.ReadWrite.All`
* `Directory.ReadWrite.All`
* `Group.Create`
* `Group.ReadWrite.All`
* `GroupMember.ReadWrite.All`
* `IdentityRiskyUser.ReadWrite.All`
* `InformationProtectionPolicy.Read.All`
* `Mail.Send`
* `Organization.Read.All`
* `Place.Read.All`
* `Policy.Read.All`
* `Policy.Read.DeviceConfiguration`
* `Reports.Read.All`
* `ReportSettings.ReadWrite.All`
* `RoleAssignmentSchedule.Read.Directory`
* `RoleManagement.Read.All`
* `RoleManagement.Read.Directory`
* `ServiceHealth.Read.All`
* `Sites.Read.All`
* `Team.Create`
* `Team.ReadBasic.All`
* `TeamMember.ReadWrite.All`
* `TeamSettings.ReadWrite.All`
* `User.ReadWrite.All`
* `UserAuthenticationMethod.ReadWrite.All`
* `WindowsUpdates.ReadWrite.All`

### その他のアプリ API のアクセス許可

次の Office 365 Exchange Online API のアクセス許可をマネージド ID に付与してください

* `Exchange.ManageAsApp`

次の WindowsDefenderATP API のアクセス許可をマネージド ID に付与してください

* `Machine.Read.All`
* `Machine.Isolate`
* `Machine.RestrictExecution`
* `Ti.ReadWrite.All`

次の SharePoint API のアクセス許可をマネージド ID に付与してください

* `User.Read.All`
* `Sites.Read.All`
* `Sites.FullControl.All`

### ロールとアクセス許可の付与

マネージド ID へのアクセス許可の付与は、現在 Azure Portal では行えません。この作業には MS Graph / PowerShell スクリプトの使用を推奨します。

{% hint style="info" %}
`Set-RJAutomationAccount` RealmJoin PowerShell モジュールから — 参照してください [Azure Automation の接続](https://docs.realmjoin.com/ja/zi-dong-hua/connecting-azure-automation.md) — ですでに次を割り当てます: **API のアクセス許可** Automation Account のセットアップまたは更新時に、Microsoft Graph、Exchange Online、Defender、SharePoint 用のものを含みます。

これは **は** 割り当てます **Entra ID ロール** 上記のものを割り当てます。また、その同梱の権限セットは、このページとは別に管理されており、このページは次に基づいて生成されています: [runbooks リポジトリ](https://github.com/realmjoin/realmjoin-runbooks)。Entra ID ロールには下のスクリプトを使用し、モジュールでカバーされていない runbook に必要な API のアクセス許可を追加してください。
{% endhint %}

この手順の例は次で確認できます [こちら](https://github.com/Workplace-Foundation/approle-and-directoryrole-granter)。必要とする JSON ファイルは、次に公開されています: [runbooks リポジトリ](https://github.com/realmjoin/realmjoin-runbooks/tree/production/docs/other/json):

```powershell
. .\GrantAppPermToEntApp.ps1 -enterpriseAppObjId "<ManagedIdentityObjectId>" -permissionsTemplate .\AllRealmJoinRunbooks_collected_permissions.json
. .\AssignAzureADRoleToEntApp.ps1 -objectId "<ManagedIdentityObjectId>" -rolesTemplate .\AllRealmJoinRunbooks_collected_rbacroles.json
```

マネージド ID のオブジェクト ID は、Azure Portal の Automation Account の Account Settings > Identity に表示されます。

### Azure リソースの権限

runbook の Azure Automation Account をホストしているサブスクリプションまたはリソース グループに、少なくとも「Contributor」アクセス権を付与してください

一部の runbook では、レポートやバックアップを保存するために Azure Storage Account を使用します。対応するサブスクリプションまたはリソース グループに、少なくとも「Contributor」アクセス権を付与してください。すると、ほとんどの runbook はそのリソース グループ内に必要なリソースを自分で作成できます。

## 認証方法

### マネージド ID

Azure Automation は次をサポートします [マネージド ID](https://docs.microsoft.com/en-us/azure/automation/enable-managed-identity-for-automation) （システム割り当て）を、認証するための主要な方法として。これは非推奨の RunAs アカウントに代わるものです。

RealmJoin Runbooks は現在、マネージド ID が構成されていない場合に RunAs アカウントをサポートしています。

{% hint style="warning" %}
マネージド ID と RunAs アカウントが同時に構成されている場合、RealmJoin の共有リポジトリの runbook は、当社のサポート対象の `RealmJoin.RunbookHelper` v0.8.0 以降のモジュールから。

モジュールの古いバージョンでは、マネージド ID を十分に活用できず、RunAs アカウントが優先されていました。

必要な権限をマネージド ID に付与するか、完全に無効化して RunAs アカウントのみを使用するようにしてください。
{% endhint %}

### クライアント シークレット

一部のプライベート runbook では、ClientID/Secret 形式の認証が必要な場合があります。現在、ClientID と Secret を必要とする共有 runbook はありません。

必要であれば、ClientID と Secret は Azure Automation Account 内の「realmjoin-automation-cred」という名前の管理対象資格情報に保存できます。

現在、automation account 内の「realmjoin-automation-cred」は既定で RJ-Wizard により作成されますが、ランダムな値が入力されています。正しい値に置き換える必要があります。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.realmjoin.com/ja/zi-dong-hua/connecting-azure-automation/azure-ad-roles-and-permissions.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
