> 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).

# Runbook 実行要件

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

## PowerShell モジュール

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

GitHub 上で利用できる共有 runbooks は [GitHub](https://github.com/realmjoin/realmjoin-runbooks) 次の Windows PowerShell モジュールを使用します:

| モジュール                            | runbooks 内の最小バージョン |
| -------------------------------- | ------------------ |
| `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             |

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

## 権限

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

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

次のロールとアクセス許可の一覧があれば、共有リポジトリで現在利用可能なすべての runbooks を使用できます。

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

### Entra ID ロール

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

* アプリケーション開発者
* Cloud Device Administrator
* Exchange 管理者
* 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`
* `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`

### その他の App 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 への接続](/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 は、Automation Account の Azure Portal で、Account Settings > Identity の下に表示されます。

### Azure リソースのアクセス許可

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

一部の runbooks では、レポートやバックアップを保存するために Azure Storage Account を使用します。対応するサブスクリプションまたはリソース グループには、少なくとも "Contributor" アクセスを付与してください。すると、多くの runbooks はリソース グループ内のリソースを自分で作成できるようになります。

## 認証方法

### マネージド 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" %}
Managed Identity と RunAs アカウントが同時に構成されている場合、RealmJoin の共有リポジトリの runbooks は、当社のサポート対象の `RealmJoin.RunbookHelper` モジュール v0.8.0 以降で、Managed Identity の使用を自動的に優先します。

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

必要なアクセス許可を Managed Identity に付与するか、完全に無効化して RunAs アカウントのみを使用するようにしてください。
{% endhint %}

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

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

必要であれば、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.
