> 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 環境のシミュレーション

新しい runbook を開発するには、Runbook 内で実行しているかのように認証するために RealmJoin.RunbookHelper を有効にする必要がある場合があります。

## 概要

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

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

<figure><img src="https://3438325150-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MkrcM7cKOpXKri1kVrh%2Fuploads%2FAELajVV85Wm6a1Mwtmew%2Fimage.png?alt=media&amp;token=15d94203-906f-4d0f-8c7b-77e8e032201b" 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 の作成方法のサンプルについては、Replace `{Variables}` を適宜置き換えてください。

次の `{AppID}` は Application Regsitrations の 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` これは Application Registration のシークレットにアップロードします。

{% hint style="info" %}
複数のアプリ / 環境に対応させたい場合は、既定の "AzureRunAsConnection" を`CN=AzureRunAsConnection` その環境の証明書を作成する際に、カスタム名に変更します。

その後、接続に使用する環境 / 証明書（例: "OtherEnv"）を次の方法で選択できます。 `Connect-RjRbGraph -AutomationConnectionName "OtherEnv"`

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

<figure><img src="https://3438325150-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MkrcM7cKOpXKri1kVrh%2Fuploads%2Fo2vVY6YO0gimSWg4XOfV%2Fimage.png?alt=media&amp;token=958b8b21-c0fa-464e-aba9-954c008eea8c" 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 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/dev-reference/simulating-a-runbook-environment.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.
