> 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 はランブックのホストとして機能し、次を提供します [権限](/ja/zi-dong-hua/connecting-azure-automation/azure-ad-roles-and-permissions.md) ランブックが環境内で機能するために必要なものです。

## 考慮事項

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

## 前提条件

* グローバル管理者権限
* 次を使用した 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 サブスクリプションに対する共同作成者権限
* [ランブック要件](/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. ［Basics］タブで、必要な Subscription、Resource Group、Automation Account 名、および Region を選択します<br>

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

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

4. ［Advanced］タブで、System Assigned Managed Identity が有効になっていることを確認します

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

{% step %}

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

RealmJoin の共有ランブックは、Azure Automation の system assigned managed identity を使用して、Entra ID、MS Graph API などと連携します。

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

1. 次の PowerShell スクリプトと JSON ファイルを同じフォルダーにダウンロードしてください。\
   このスクリプトは 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="RJvNextPermissions.json" %}
{% @github-files/github-code-block url="<https://github.com/Workplace-Foundation/approle-and-directoryrole-granter/blob/main/RealmJoinVnext/RJvNextPermissions.json>" %}
{% endtab %}

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

2. Account Settings > Identity で、Azure Automation Account の Managed Identity の Object 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 の Object ID に置き換えてください

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

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

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

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

{% step %}

#### RealmJoin ランブックの構成 - パート 1

1. RealmJoin Portal で「[設定 -> 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 名を入力します\
   Entra ID の [概要ページの Tenant ID](https://portal.azure.com/#blade/Microsoft_AAD_IAM/ActiveDirectoryMenuBlade/Overview)

   <figure><img src="/files/4651a9dcb9e1cd6a07d9ec2dcab8ea37dd146eea" alt=""><figcaption></figcaption></figure>
3. 下の赤字のスクリプトをコピーします *ResourceGroup.*\
   このスクリプトは、Entra ID に Service Principal を作成し、Automation Account へのアクセスを付与することで、RealmJoin がランブックの管理、実行、監視を行えるようにします。\
   スクリプトは 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`.\
   App Registration「RealmJoin Runbook Management」が作成されます。<br>

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

{% step %}

#### RealmJoin ランブックの構成 - パート 2

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

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

6. 最初のランブックのインポートを開始するには「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:

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

The question should be specific, self-contained, and written in natural language.
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.
