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

# Azure Automation の接続

## 概要

{% embed url="<https://www.youtube.com/watch?v=Ijp9XnE8UuA>" %}

RealmJoin Portal が配信できるようにするには [ランブック ](/ja/zi-dong-hua/runbooks.md)日々のタスクを自動化するには、次のものを接続する必要があります [Azure Automation](https://learn.microsoft.com/en-us/azure/automation/overview) アカウント。この Automation Account は、runbooks のホストとして機能し、次のものを提供します [権限](/ja/zi-dong-hua/connecting-azure-automation/azure-ad-roles-and-permissions.md) お使いの環境内で runbooks を機能させるために必要な

## 考慮事項

Automation Account の [Managed Identity](https://learn.microsoft.com/en-us/azure/active-directory/managed-identities-azure-resources/overview) には広範な [権限 ](/ja/zi-dong-hua/connecting-azure-automation/azure-ad-roles-and-permissions.md)お使いの環境では、Entra ID のグループやユーザー オブジェクトを変更したり、Exchange Online でメールボックスを管理したりできるなどの権限が必要です。これらの権限の悪用を防ぐため、このアカウントへの管理者アクセスは最小限に制限してください。

既存の Automation Account を使用する場合、RealmJoin Portal が次から取得した runbooks を自動的に作成、更新、削除することに注意してください [共有オンライン runbooks リポジトリ](https://github.com/realmjoin/realmjoin-runbooks)。この機能は既存の Automation Account ではサポートされない場合があります。不明な場合は、RealmJoin Runbooks 用に専用の Azure Automation Account を作成することをお勧めします。

## 前提条件

* Global Administrator 権限
* 次を使用した PowerShell へのアクセス: [Az](https://learn.microsoft.com/en-us/powershell/azure/?view=azps-15.3.0) モジュール、または [AZ CLI](https://learn.microsoft.com/en-us/cli/azure/?view=azure-cli-latest)
* Azure サブスクリプションでの Contributor 権限
* [Runbook の要件](/ja/zi-dong-hua/connecting-azure-automation/azure-ad-roles-and-permissions.md)

## 手順

{% stepper %}
{% step %}

#### Azure Automation Account を作成する

1. 次へ移動します: [Azure Portal > Automation Accounts](https://portal.azure.com/#create/Microsoft.AutomationAccount)
2. 新しい Automation Account を作成する
3. ［基本］タブで、目的の Subscription、Resource Group、Automation Account 名、リージョンを選択します<br>

   <figure><img src="/files/558807d9e5dc3ff69a1f10e95dd9467cea3711ee" alt=""><figcaption></figcaption></figure>

{% hint style="success" %}
Automation Account 用に個別の Resource Group を用意することをお勧めします
{% endhint %}

4. ［詳細］タブで、システム割り当ての Managed Identity が有効になっていることを確認します

   <figure><img src="/files/cebce7ea795223f29dc5b7c19035707ae50ca89f" alt=""><figcaption></figcaption></figure>
5. ［レビュー + 作成］を選択して、Automation Account を作成します
6. Azure Automation Account を含む Resource Group へ移動します
7. ［IAM］タブで、Azure Automation Account に Contributor を割り当てます
   {% endstep %}

{% step %}

#### Azure Automation Account に権限を割り当てる

RealmJoin の共有 runbooks は、Azure Automation のシステム割り当て Managed Identity を使用して、Entra ID、MS Graph API などと連携します。

Managed Identity の権限は、現在 Azure Portal からは付与できません。これらの権限の割り当てには Microsoft Graph または PowerShell を使用してください。

1. 以下の PowerShell スクリプトと JSON ファイルを同じフォルダーにダウンロードします。\nこのスクリプトは RealmJoin に必要な完全な権限セットを割り当てます。ロールと権限は、次のセクションで確認できます: [要件](/ja/zi-dong-hua/connecting-azure-automation/azure-ad-roles-and-permissions.md) セクションで確認でき、必要に応じて JSON ファイルで調整できます。

{% tabs %}
{% tab title="GrantAppPermToEntApp.ps1" %}
{% @github-files/github-code-block url="<https://github.com/Workplace-Foundation/approle-and-directoryrole-granter/blob/main/GrantAppPermToEntApp.ps1>" %}
{% endtab %}

{% tab title="AssignAzureADRoleToEntApp.ps1" %}
{% @github-files/github-code-block url="<https://github.com/Workplace-Foundation/approle-and-directoryrole-granter/blob/main/AssignAzureADRoleToEntApp.ps1>" %}
{% endtab %}

{% tab title="AllRealmJoinRunbooks\_collected\_permissions.json" %}
{% @github-files/github-code-block url="<https://github.com/realmjoin/realmjoin-runbooks/blob/production/docs/other/json/AllRealmJoinRunbooks_collected_permissions.json>" %}
{% endtab %}

{% tab title="AllRealmJoinRunbooks\_collected\_rbacroles.json" %}
{% @github-files/github-code-block url="<https://github.com/realmjoin/realmjoin-runbooks/blob/production/docs/other/json/AllRealmJoinRunbooks_collected_rbacroles.json>" %}
{% endtab %}
{% endtabs %}

2. ［アカウント設定］>［ID］で、Azure Automation Account の Managed Identity のオブジェクト ID を控えておきます

   <figure><img src="/files/8aeef31c277a4dbf352d75304e181d617737a475" alt=""><figcaption></figcaption></figure>
3. PowerShell ウィンドウを開きます。
4. ダウンロードしたファイルがあるフォルダーへ移動します

```
cd c:\temp\myfolder
```

5. 必要に応じてスクリプトのブロックを解除します\
   ![](/files/000f14430797f2dc09cacdb8829c22d9e00f4cbc)
6. GrantAppPermToEntApp.ps1 を使用して Azure Automation Account に MS Graph の権限を割り当てます。xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx は Automation Account のオブジェクト ID に置き換えてください

```
. .\GrantAppPermToEntApp.ps1 -enterpriseAppObjId "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" -permissionsTemplate .\AllRealmJoinRunbooks_collected_permissions.json
```

7. AssignAzureADRoleToEntApp.ps1 を使用して Azure Automation Account に Entra ID の管理者ロールを割り当てます。xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx は Automation Account のオブジェクト ID に置き換えてください

```
. .\AssignAzureADRoleToEntApp.ps1 -objectId "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" -rolesTemplate .\AllRealmJoinRunbooks_collected_rbacroles.json
```

8. Azure Automation Account には、これで Runbooks を実行するための正しい権限が設定されています<br>
   {% endstep %}

{% step %}

#### RealmJoin Runbook 設定 - パート 1

1. RealmJoin Portal で '[Settings -> Runbooks](https://portal.realmjoin.com/settings/runbooks-configuration)'.<br>

   <figure><img src="/files/73e470bc8262e8f5956298238e47bcecc72cbb04" alt=""><figcaption></figcaption></figure>
2. Azure Automation Account に対応する Tenant ID、Subscription ID、Resource Group 名を入力します\n次の Tenant ID は [Entra ID の概要ページ](https://portal.azure.com/#blade/Microsoft_AAD_IAM/ActiveDirectoryMenuBlade/Overview)

   <figure><img src="/files/4651a9dcb9e1cd6a07d9ec2dcab8ea37dd146eea" alt=""><figcaption></figcaption></figure>
3. 下にある赤字のスクリプトをコピーします *ResourceGroup.*\
   このスクリプトは、Automation Account へのアクセスを持つ Service Principal を Entra ID に作成し、RealmJoin が runbooks を管理、実行、監視できるようにします。\nスクリプトは、Tenant ID、Subscription ID、Resource Group の入力に基づいて更新されます。<br>

   <figure><img src="/files/5221b368bf8ec49f8d0beb372006fb3e8097d72a" alt=""><figcaption></figcaption></figure>
4. ウィザードはしばらく開いたままにしておいてください。続きはパート 2 ですぐに戻ります。
   {% endstep %}

{% step %}

#### RealmJoin に Azure Automation へのアクセスを付与する

{% hint style="info" %}
次を使用できます: [Azure CloudShell](https://docs.microsoft.com/en-us/azure/cloud-shell/overview)。そのため、ローカルに AZ CLI をインストールして認証する必要はありません。
{% endhint %}

1. 前にコピーしたスクリプトを PowerShell で実行します。

   <figure><img src="/files/9e791e225e968fff364176be96bd3447ce177a15" alt=""><figcaption></figcaption></figure>
2. 次の値を控えておきます: `appId` および `password`。\nアプリ登録「RealmJoin Runbook Management」が作成されます。<br>

   ![Azure Portal の App Registrations](/files/16ce1f21dd091192d47b796c064d4dd959bb6088)
   {% endstep %}

{% step %}

#### RealmJoin Runbook 設定 - パート 2

1. RealmJoin Portal で、開いているウィンドウ/ウィザード ' に戻ります[Settings -> Runbooks](https://portal.realmjoin.com/settings/runbooks-configuration)'
2. 不足している値を入力します: `appId` および `password` 前の手順で作成された
3. 作成した Automation Account の名前を入力します [前述の](#create-an-azure-automation-account)
4. 追従する共有 runbook リポジトリのブランチを選択します。\n不明な場合は、次を選択してください: `production`\
   すべての runbook ブランチはここで確認できます: <https://github.com/realmjoin/realmjoin-runbooks>
5. runbooks が正しい場所で実行されるよう、Azure Automation Account と同じ場所を選択してください [Azure region](https://docs.microsoft.com/en-us/azure/availability-zones/az-overview)

![RealmJoin Portal の Automation Account 接続](/files/7136a85ec0d1d89eb9598c65ba74c02a2590659b)

6. runbooks の初回インポートを開始するには、「Save」を押してください。「Sync completed」というメッセージが表示されるまで、このウィンドウは開いたままにしてください。

![](/files/7bca85aae4b6c741b94769171f3a95bd3ef0a4d1)
{% endstep %}
{% endstepper %}


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
