> 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/dev-reference/simulating-a-runbook-environment.md).

# Runbook 環境のシミュレーション

## 概要

### アプリケーション登録を作成する

Microsoft Entra へのアプリケーション形式のサインインをシミュレートするために、Azure のアプリケーション登録を作成します。

<figure><img src="/files/60a30ee41b0e9836382d7b03bce4a9d2c9050004" alt=""><figcaption><p>アプリ登録を作成する</p></figcaption></figure>

### アクセス許可を付与する

マネージド ID と同じアクセス許可を付与します。同じ [AppRoleGranter Toolkit](https://github.com/hcoberdalhoff/approle-and-directoryrole-granter) をこの目的のために使用します。

置き換えてください `{AppRegObjectId}` を、アプリケーション登録のオブジェクト ID で。

```powershell
git clone https://github.com/hcoberdalhoff/approle-and-directoryrole-granter.git
cd "approle-and-directoryrole-granter\RealmJoinVnext"
. .\AllInOne.ps1 -appRegObjectId "{AppRegObjectId}"
```

### Dev-Certificate を作成してアップロードする

参照 [こちら ](https://github.com/realmjoin/RealmJoin.RunbookHelper/blob/main/DevCertificates.ps1)RunbookHelper Dev-Certificate の作成方法のサンプルです。置き換えてください `{Variables}` それに応じて。

この `{AppID}` は、アプリケーション登録の App / Client ID を指します。

特定のサブスクリプション ID がない場合は、Tenant の既定のサブスクリプションを使用してください。（ほとんどの場合、違いはありません。）

```powershell
New-SelfSignedCertificate -Subject 'CN=AzureRunAsConnection, OU={AppID}, DC={TenantID}, O={SubscriptionID}' `
    -CertStoreLocation "cert:\CurrentUser\My" -NotAfter (Get-Date).AddYears(10) -KeySpec Signature | `
    Export-Certificate -FilePath "AzureRunAsConnection.cer"
```

次のファイルが作成されます `AzureRunAsConnection.cer` これは、アプリケーション登録のシークレットにアップロードします。

{% hint style="info" %}
複数のアプリ / 環境を提供したい場合は、既定の "AzureRunAsConnection" を`CN=AzureRunAsConnection` その環境用の証明書を作成するときにカスタム名に置き換えることができます。

その後、どの環境/証明書（たとえば "OtherEnv"）に接続するかを次で選択できます `Connect-RjRbGraph -AutomationConnectionName "OtherEnv"`

これにより、同じマシンから複数の環境にアクセスできます。
{% endhint %}

<figure><img src="/files/7bfc20194b9d869c95fe6464671b30ed834cbbc0" alt=""><figcaption><p>証明書のアップロード</p></figcaption></figure>

### 使用方法

次を使用するだけです `Connect-RjRbGraph` アプリに対して認証します。

競合やログイン失敗を避けるため、個人証明書ストアに古い Dev-Certificates がある場合は、mmc.exe を使って必ず削除してください。


---

# 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/dev-reference/simulating-a-runbook-environment.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.
