> For the complete documentation index, see [llms.txt](https://docs.scepman.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.scepman.com/ja/scepman-nodepuroi/permissions/post-installation-config.md).

# マネージド ID

{% hint style="info" %}
この機能にはバージョン **2.0** 以降が必要です。
{% endhint %}

SCEPman は、ユーザーとデバイスの証明書および OCSP 検証を提供するために、Entra Directory と Intune のエンドポイントとやり取りする必要があります。デプロイ後、SCEPman にはまだこれらのサービスにアクセスするために必要な権限がありません。この記事で説明する PowerShell Module は、必要な権限を SCEPman App Service の Managed Identity に追加し、インストールを完了します。

さらに、PowerShell Module は、SCEPman 2.0 で導入された SCEPman Certificate Master コンポーネントに必要なバックグラウンド配線を追加します。SCEPman 1.x から SCEPman 2.x にアップグレードした場合、PowerShell Module は SCEPman Certificate Master コンポーネント用に 2 つの新しい Azure リソースも追加します。

## SCEPman インストール PowerShell Module を取得して実行する

新規の SCEPman 2.x をインストールしたばかりでも、SCEPman 1.x から SCEPman 2.x にアップグレードしたばかりでも、また場合によってはデプロイ アーキテクチャの変更後でも、インストール手順は同じです。SCEPman PowerShell Module をダウンロードして実行すると、何をすべきかを検出してインストールを完了します。SCEPman Module は好きなだけ何度でも実行でき、まだ不足しているものだけを追加します。

### 前提条件

* A **全体管理者** SCEPman をインストールしたい Tenant のアカウント（または、次のような別の AAD ロール: *特権ロール管理者* および Azure Subscription への書き込み権限）。次の権限のみを持つアカウントを使用することもできます: *アプリケーション管理者* ロールを使用し、Global Administrator 権限が必要なコマンドは後で手動で実行することもできます。
* [Azure CLI](https://docs.microsoft.com/en-us/cli/azure/install-azure-cli) （別名 *az*）がインストールされていること。Azure CLI は次にあらかじめインストールされています: [Azure Cloud Shell](https://docs.microsoft.com/en-us/azure/cloud-shell/overview)。これはモジュールを実行する推奨方法です。

### SCEPman インストール CMDlet の実行

#### 有効なホームページ

前提条件が満たされたら、PowerShell Gallery から SCEPman インストール モジュールをインストールし、CMDlet を実行して SCEPman と Certificate Master のインストールを完了します。

1. まず、SCEPman App Service に移動し、Default domain をクリックする必要があります（下のスクリーンショットを参照）。これで SCEPman のホームページに移動します。

<figure><img src="https://114237723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LoGejQeUQcw7lqnQ3WX%2Fuploads%2FOpFw5ty3cTxb27sfldRx%2F2024-04-17%2016_16_16.png?alt=media&amp;token=ee0ac055-4107-494d-9990-8a610fbec7f7" alt=""><figcaption></figcaption></figure>

2. PowerShell または Azure Cloud Shell で、SCEPman インスタンスのホームページに表示されている PowerShell コマンドを実行します（下のスクリーンショットを参照）。これには SCEPman インスタンスを識別するためのパラメーターが含まれているため、コードは理想的にはユーザーの操作なしで実行できます。

![](https://114237723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LoGejQeUQcw7lqnQ3WX%2Fuploads%2Fgit-blob-9189fc6b1b39a7ba68b3add0dfe55427083ef43e%2F2022-04-07SCEPmanV2.0AfterNewInstallation.png?alt=media)

{% hint style="warning" %}
CMDlet を実行した後、SCEPman のホームページで「Service not available」または「502 Server Error」が表示されることがあります。2～3 分待ってから、ページを再読み込みしてください。
{% endhint %}

#### ホームページ無効

SCEPman のホームページを無効にしている場合、または CMDlet を再度実行する必要がある場合は、次の手順を実行してください:

1. PowerShell または Azure Cloud Shell に以下のコードを貼り付けます:

```
Install-Module SCEPman -Scope CurrentUser -Force
Complete-SCEPmanInstallation 6>&1
```

2. 次のプロンプトに入力します:

* SCEPman が実行されている Azure Subscription（アクセス権を持つものが複数ある場合）
* SCEPman App Service の名前（SCEPman ホームページのコードを使用した場合は不要）

3. （SCEPman のアップグレードの場合のみ）、追加で 2 つの確認が必要です:

* 新しい SCEPman Certificate Master App Service の名前（Enter キーで提案を確定するか、リソースの新しい名前を入力できます）
* 新しい Storage Account リソースの名前（同様に、Enter キーで提案を確定するか、リソースの新しい名前を入力できます）

### Global Admin ロールなしで SCEPman インストール CMDlet を実行する

次を使用します: *-SkipAppRoleAssignments* Complete-SCEPmanInstallation のフラグを使用すると、Global Admin 権限なしで CMDlet を実行できます。これにより、SCEPman および Certificate MasterApp Services の Managed Identities に必要な App Roles の割り当てがスキップされます。その後、Global Administrator として App Roles を手動で割り当てることができます。CMDlet は必要なコマンドをコンソールに出力します。

### Deployment Slots を使用する際の考慮事項

SCEPman module は、特定の 1 つの deployment slot だけを使用するようにパラメーター `-DeploymentSlotName` で指定しない限り、すべての deployment slot の構成を更新します（main の slot は技術的には deployment slot ではないため、指定できません）。構成更新により、SCEPman の設定は次のように変更されます: **使用** **Enterprise App 認証ではなく Managed Identity 認証を**.

SCEPman 1.x **はサポートしていません** Managed Identity 認証をサポートしていないため、CMDlet により、1.x バージョンをまだ実行している deployment slot は使用できなくなります。したがって、複数の deployment slot があり、それらを一度にすべてアップグレードしたくない場合は、production slot を最後に更新する必要があります -- **そのアップグレードは他のすべての deployment slot にも影響するためです**.

他の deployment slot には、次のものを使用して `-DeploymentSlotName` パラメーターを使用し、これらの個々の deployment slot のみを対象にします。これは deployment slot の SCEPman ホームページに表示される PowerShell コマンドに反映されているので、コマンドをそのままコピーできます。

すべての deployment slot が 2.x で実行されている状態になったら、Complete-SCEPmanInstallation CMDlet をもう一度実行するだけで、すべてが Managed Identities を使用するようになります。

{% hint style="danger" %}
誤って SCEPman 1.x をまだ実行している deployment slot を Managed Identity 認証に更新してしまった場合は、 [ダウングレード ガイド](https://docs.scepman.com/ja/scepman-nodepuroi/permissions/pages/514b43b3dacbc9f3f011125d8f806184425e36ce#downgrade-from-2.x-to-1.x) を参照して、再び動作するようにしてください。
{% endhint %}

### 1 つの Tenant に SCEPman を複数回インストールする際の考慮事項

CMDlet Complete-SCEPmanInstallation は 2 つの App Registration を作成します: `SCEPman-api` および `SCEPman-CertMaster`. [セクション「CMDlet が SCEPman Certificate Master を構成する方法](#how-the-cmdlet-configures-scepman-certificate-master)」では、これらの App Registrations が何をするのかを説明しています。CMDlet はそれらの名前が一意であることを要求するため、1 つのテナントに複数の SCEPman インストールがある場合、既定ではこれらの App Registrations を共有します。つまり、ユーザーはすべての Certificate Masters で同じロールを持ち、技術的には各 Certificate Master インスタンスが任意の SCEPman に証明書要求を送信できます（ただし、SCEPman Certificate Master をそのように構成しない限り、そのようなことは起こりません）。

この動作を望まない場合、たとえば SCEPman のインストールが組織の異なる部門に属している場合、あるいは 1 つの SCEPman インストールが本番前環境である場合、または SCEPman Root CA と SCEPman Issuing CA を備えたマルチティア PKI を構成したい場合は、SCEPman インスタンスに別の app registrations を使用するよう指示する必要があります。

そのために、Complete-SCEPmanInstallation CMDlet には次の 2 つのパラメーターがあります `-AzureADAppNameForSCEPman` および `-AzureADAppNameForCertMaster`。これらのパラメーターを使うと、App Registration に異なる名前を定義できます。たとえば、Root CA では次のように CMDlet を呼び出せます:\
`Complete-SCEPmanInstallation -SCEPmanAppServiceName app-scepmanroot -SearchAllSubscriptions -AzureAdAppNameForSCEPman SCEPman-api-root -AzureAdAppNameForCertMaster -SCEPman-CertMaster-root 6>&1`

そして、Subordinate CA については次のようにもう一度呼び出します:

`Complete-SCEPmanInstallation -SCEPmanAppServiceName app-scepmansub -SearchAllSubscriptions -AzureAdAppNameForSCEPman SCEPman-api-sub -AzureAdAppNameForCertMaster -SCEPman-CertMaster-sub 6>&1`

## SCEPman PowerShell Module の背景詳細

このセクションでは、PowerShell Module の内部動作を説明します。これは、スクリプトの変更が必要な特殊な構成がある場合、特別な権限を付与する必要がある場合、SCEPman のインストールに関する問題をトラブルシューティングする場合、または独自のプロジェクト用のインストール スクリプトを作成するために内部動作を理解したい場合に役立ちます。PowerShell Module は Open Source Software であることに注意してください。ソースコードはその [GitHub リポジトリ](https://github.com/scepman/scepman-psmodule)。Pull Request を歓迎します！

コマンドレットは次を付けて実行することを推奨します: `6>&1`、これにより情報ストリームがリダイレクトされ、画面に出力されます。これは、リダイレクトしない場合よりもプログラムの状態に関するより多くの情報を得られます。さらに `-Verbose`を追加すると、スクリプトが何を行っているかについてさらに多くの情報が表示されます。

### CMDlet が SCEPman を構成する方法

PowerShell CMDlet は SCEPman App Service を検索します。App Service は system-assigned Managed Identity を使用しており、通常のインストールではすでに SCEPman の Azure Key Vault へのアクセス権を持っています。CMDlet は、受信 OCSP 要求に対して AAD と Intune でユーザーおよびデバイスを検索するための Microsoft Graph へのアクセス権限と、受信 SCEP 要求を検証するための Intune 自体への権限を追加します。

### CMDlet が SCEPman 1.x からの更新を処理する方法

SCEPman に権限を付与することに加えて、Module はアップグレード時に 2 つの新しい Azure リソースを追加します:

* SCEPman Certificate Master App Service
* SCEPman と SCEPman Certificate Master で共有される、手動で作成された証明書用の Storage Account

SCEPman Certificate Master コンポーネントを使用しない Community Edition でも、2 つの新しいリソースが追加されます。これにより、必要に応じて Enterprise Edition へより簡単に切り替えられ、追加費用も発生しません -- Storage Account は空のままで、Microsoft はこれをストレージ容量に応じて課金し、Certificate Master App Service は SCEPman と App Service Plan を共有するため、これも追加費用はかかりません。

SCEPman 1.x では Microsoft Graph と Intune に対する認証に App Registration を使用していましたが、SCEPman 2.x では Managed Identity を使用できます。CMDlet は次の設定を変更することで Managed Identity に切り替えます:

* [AppConfig:AuthConfig:ApplicationId](/ja/scepman-gou-cheng/application-settings/dependencies-azure-services/azure-ad.md#appconfigauthconfigapplicationid) は、権限を持たない新しく作成された app registration に設定されます。これは認証に使用されます *に対して* SCEPman に対するものであり、SCEPman が別の場所で認証するためのものではありません。古い値は次の名前でバックアップされます: `Backup:AppConfig:AuthConfig:ApplicationId`.
* [AppConfig:AuthConfig:ApplicationKey](/ja/scepman-gou-cheng/application-settings/dependencies-azure-services/azure-ad.md#appconfigauthconfigapplicationkey) は削除され、古い値は次の名前でバックアップされます: `Backup:AppConfig:AuthConfig:ApplicationKey`。これはもう必要ありません。SCEPman は Application として認証しないためです。
* [AppConfig:AuthConfig:ManagedIdentityEnabledOnUnixTime](/ja/scepman-gou-cheng/application-settings/dependencies-azure-services/azure-ad.md#appconfigauthconfigmanagedidentityenabledonunixtime) には、CMDlet が実行された時刻が含まれます。SCEPman は、CMDlet の実行後しばらくしてから Managed Identity を使用してトークンを取得します。というのも、その時点で初めてトークン内のロールが CMDlet によって追加された正しい権限を反映するからです。

### CMDlet が SCEPman Certificate Master を構成する方法

SCEPman App Service は、機密性のない読み取り専用情報のみを表示するため、ホームページへの匿名アクセスを許可します。対照的に、SCEPman Certificate Master コンポーネントはユーザーに証明書の発行を許可します。そのため、認証済みアクセスのみを許可し、適切な権限がある場合に限ります。これには、ログイン中のユーザーを確認するための Delegated Permissions を持つ Azure App Registration と、適切なログイン URL 設定が必要です。モジュールはこの App Registration を次のように登録します: `SCEPman-CertMaster` あなたの Azure テナント内に。

さらに、SCEPman Certificate Master App Service は、証明書を発行するために Certificate Signing Requests (CSRs) をコアの SCEPman App Service に送信する権限が必要です。これを支える認証メカニズムは、別の App Registration に基づいています: `SCEPman-api`。SCEPman は次を使用します: *SCEPman-api* を使って CSR 送信権限を管理します。スクリプトは SCEPman-api を登録し、送信権限を SCEPman Certificate Master の Managed Identity に追加します。

{% hint style="info" %}
SCEPman を 1.x から 2.x にアップグレードし、PS スクリプトが正常に実行された場合は、SCEPman 1.x で使用されていた App Registration を削除できます

SCEPman V2.x では 2 つの新しい App Registration「SCEPman-api」と「SCEPman-CertMaster」を使用します
{% endhint %}


---

# 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.scepman.com/ja/scepman-nodepuroi/permissions/post-installation-config.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.
