高度なインストール:Entra ID アプリを作成します

従来の Nerdio Manager デプロイメントでは、インストールガイドに記載されている手順と指示に従う必要があります。詳細については、「Nerdio Manager インストールガイド」を参照してください。ここに記載されている高度なインストール方法は、必要に応じて特定の状況でのみ使用してください。

警告

これは Nerdio Manager の高度なカスタムインストールであり、特別な状況でのみお勧めです。Nerdio Supportのアドバイスとガイダンスに従って使用してください。ご不明な点がございましたら、nme.support@getnerdio.com までお問い合わせください。

注記

Nerdio Managerの更新には、Cloud ShellまたはPowerShellスクリプトの実行が必要です。詳細については、アプリのNerdio Manager更新を参照してください。

注記

この記事の PowerShell スクリプトは、Azure Cloud Shell にプリインストールされている Microsoft Graph PowerShell SDK を使用します。他の場所で実行するには、まず必要なモジュールをインストールしてください。Install-Module Microsoft.Graph.Authentication, Microsoft.Graph.Applications, Microsoft.Graph.Users -Scope CurrentUser。各スクリプトは Connect-MgGraph でサインインし、必要な権限を要求します。そのセクションで指定された管理者としてサインインしてください。

Entra ID で Nerdio Manager アプリケーションを手動で作成するための高度なインストール手順

  • Azure Marketplace デプロイメント (サブスクリプション所有者が完了します)。

  • Entra ID アプリケーション登録とセットアップ (グローバル管理者、または特権ロール管理者とクラウド アプリケーション管理者の組み合わせが完了します)。

  • Azure リソース構成 (サブスクリプション所有者が完了します)。

Entra ID アプリケーションの手順を 1 回で完了するには、すべての手順を 1 つのスクリプトで実行するを参照してください。

アプリとサービス プリンシパルを作成します

以下の手順で、アプリとサービス プリンシパルを作成します。

アプリとサービス プリンシパルを作成するには:
  1. Azure ポータルで、Microsoft Entra ID > アプリの登録 > 新規登録 に移動します。

  2. 次の情報を入力してください:

    • 名前: nerdio-nmw-app (必要に応じてデフォルトのアプリ名を変更してください)

    • アカウントタイプ[この組織ディレクトリ内のアカウントのみ (シングル テナント)]

    • リダイレクト URL:Web, https://<app_service_name>.azurewebsites.net/

  3. アプリ ID を保存します。(Nerdio Manager 展開用に提供されます。)

  4. Microsoft Entra ID > アプリの登録 > すべてのアプリケーション > nerdio-nmw-app (またはカスタムアプリ名) > 認証 に移動します。

  5. 次の情報を入力してください:

    • Redirect URLs > Add URL: https://<app_service_name>.azurewebsites.net/signin-oidc

    • Front-channel logout URL: https://<app_service_name>.azurewebsites.net/signout-oidc

    • 暗黙的な許可とハイブリッド フロー:アクセス トークンと ID トークンは選択しないでください。

  6. Microsoft Entra ID > エンタープライズ アプリケーション > すべてのアプリケーション > nerdio-nmw-app (またはカスタムアプリ名) に移動します

  7. オブジェクト ID を保存します。(Nerdio Manager 展開用に提供されます。)

  8. あるいは、以下のPowerShellスクリプトを使用してこれらの変更を完了することもできます。

    $webAppName = "" # REQUIRED: Name of app service provisioned in marketplace deployment
    $appName = "nerdio-nmw-app" # Optionally rename the default application
    Connect-MgGraph -Scopes "Application.ReadWrite.All"
    $webAppUrl = 'https://' + $webAppName + '.azurewebsites.net/'
    $loginUrl = $webAppUrl + 'signin-oidc'
    $logoutUrl = $webAppUrl + 'signout-oidc'
    $application = New-MgApplication -DisplayName $appName -SignInAudience "AzureADMyOrg" -Web @{
        HomePageUrl           = $webAppUrl
        LogoutUrl             = $logoutUrl
        RedirectUris          = @($webAppUrl, $loginUrl)
        ImplicitGrantSettings = @{ EnableAccessTokenIssuance = $false; EnableIdTokenIssuance = $false }
    }
    $servicePrincipal = New-MgServicePrincipal -AppId $application.AppId -AppRoleAssignmentRequired:$true -Tags @("WindowsAzureActiveDirectoryIntegratedApp")
    Write-Host "Application ID to be saved in to app service: $($application.AppId)"
    Write-Host "Service Principal ID to be provided to Nerdio Manager deployment: $($servicePrincipal.Id)"
    

アプリロールを設定し、AVD管理者をアサインする

以下の手順で、アプリロールを設定し、AVD管理者をアサインします。

注記

アプリロールには、各役割ごとに特定の ID をアサインする必要があります。役割名、説明、および ID は、アプリ登録に変更することで追加できます。

アプリロールを設定し、AVD管理者をアサインするには:
  1. Azureポータルで [Microsoft Entra ID] > [アプリの登録] > [すべてのアプリケーション] > [nerdio-nmw-app] (またはカスタムアプリ名) > [マニフェスト] に移動します。

  2. "appRoles": [] エントリ (通常は8行目) を以下の値に置き換えます。

    "appRoles": [
        {
        "allowedMemberTypes": [
            "User"
        ],
        "description": "Complete access to all areas of NMW.",
        "displayName": "WVD Admin",
        "id": "d1c2ade8-98f8-45fd-aa4a-6d06b947c66f",
        "isEnabled": true,
        "origin": "Application",
        "value": "WvdAdmin"
        },
        {
        "allowedMemberTypes": [
            "User"
        ],
        "description": "Complete access to User sessions, ability to view Host Pools, hosts and restart them, but no ability to add/remove or change any settings.",
        "displayName": "Desktop Admin",
        "id": "ed0cdef0-4267-4470-bfff-5e0b6944f9e4",
        "isEnabled": true,
        "origin": "Application",
        "value": "DesktopAdmin"
        },
        {
        "allowedMemberTypes": [
            "User"
        ],
        "description": "Complete access to User sessions only.",
        "displayName": "Help Desk",
        "id": "a94e83da-b314-4232-b8c8-94508c5ed533",
        "isEnabled": true,
        "origin": "Application",
        "value": "HelpDesk"
        },
        {
        "allowedMemberTypes": [
            "User"
        ],
        "description": "View access to all areas of NMW; no ability to save or make changes.",
        "displayName": "Reviewer",
        "id": "0a1b7425-f55a-44a6-9caa-b9a5cc9448da",
        "isEnabled": true,
        "origin": "Application",
        "value": "Reviewer"
        },
        {
        "allowedMemberTypes": [
            "User"
        ],
        "description": "View & manage own sessions (Message, Log off, Disconnect). Personal desktop users can restart, power off and power their personal desktops.",
        "displayName": "End-user",
        "id": "e856de81-1e53-486a-8668-7d564866ae39",
        "isEnabled": true,
        "origin": "Application",
        "value": "EndUser"
        },
        {
        "allowedMemberTypes": [
            "Application"
        ],
        "description": "Rest client description",
        "displayName": "Rest client display name",
        "id": "3807160f-e77a-4fcf-959a-df572bcc3767",
        "isEnabled": true,
        "origin": "Application",
        "value": "RestClient"
        }
    ],
  3. [保存] を選択します。

  4. [アプリの役割] で、各役割が利用可能であることを確認します。

  5. [Microsoft Entra ID] > [エンタープライズ アプリケーション] > [すべてのアプリケーション] > [nerdio-nmw-app] (またはカスタムアプリ名) > [プロパティ] に移動します。

  6. [ユーザーに表示する?] オプションが [はい] に設定されていることを確認します。

  7. [Microsoft Entra ID] > [エンタープライズ アプリケーション] > [すべてのアプリケーション] > [nerdio-nmw-app] (またはカスタムアプリ名) > [ユーザーとグループ] > [ユーザーまたはグループの追加] に移動します。

  8. 次の情報を入力してください:

    • ユーザーとグループ:Azureポータルで Nerdio Manager デプロイを完了するユーザーを選択して検索します。

    • 役割を選択する:ドロップダウンリストから [WVD Admin] を選択します。

  9. 必要な情報をすべて入力したら、OKを選択します。

  10. あるいは、以下のPowerShellスクリプトを使用してこれらの変更を完了することもできます。

    $userPrincipalName = "" # REQUIRED: Fill in UPN of subscription owner completing Nerdio Manager deployment
    $appName = "nerdio-nmw-app" # Optionally rename the default application
    Connect-MgGraph -Scopes "Application.ReadWrite.All","AppRoleAssignment.ReadWrite.All","User.Read.All"
    function BuildAppRole([string] $displayName, [string] $value, [Guid] $id, [string] $description) {
        return @{
            AllowedMemberTypes = @("User")
            Description        = $description
            DisplayName        = $displayName
            Id                 = $id
            IsEnabled          = $true
            Value              = $value
        }
    }
    function GetNewAppRoles() {
        $reviewer = BuildAppRole -displayName "Reviewer" -value "Reviewer" -id "0a1b7425-f55a-44a6-9caa-b9a5cc9448da" -description "View access to all areas of NMW; no ability to save or make changes."
        $helpDesk = BuildAppRole -displayName "Help Desk" -value "HelpDesk" -id "a94e83da-b314-4232-b8c8-94508c5ed533" -description "Complete access to User sessions only."
        $endUser = BuildAppRole -displayName "End-user" -value "EndUser" -id "e856de81-1e53-486a-8668-7d564866ae39" -description "View & manage own sessions (Message, Log off, Disconnect). Personal desktop users can restart, power off and power their personal desktops."
        $desktopAdmin = BuildAppRole -displayName "Desktop Admin" -value "DesktopAdmin" -id "ed0cdef0-4267-4470-bfff-5e0b6944f9e4" -description "Complete access to User sessions, ability to view Host Pools, hosts and restart them, but no ability to add/remove or change any settings."
        $wvdAdmin = BuildAppRole -displayName "WVD Admin" -value "WvdAdmin" -id 'd1c2ade8-98f8-45fd-aa4a-6d06b947c66f' -description "Complete access to all areas of NMW."
        return @($reviewer, $helpDesk, $endUser, $desktopAdmin, $wvdAdmin)
    }
    $application = Get-MgApplication -Filter "displayName eq '$appName'"
    if (-not $application) {
        throw "No application found with the display name '$appName'. Check that the app registration exists and the name matches exactly."
    }
    if (@($application).Count -gt 1) {
        throw "More than one application found with the display name '$appName'. Resolve this manually before continuing."
    }
    $user = Get-MgUser -Filter "userPrincipalName eq '$userPrincipalName'"
    if (-not $user) {
        throw "No user found with the user principal name '$userPrincipalName'."
    }
    $servicePrincipal = Get-MgServicePrincipal -Filter "appId eq '$($application.AppId)'"
    Update-MgApplication -ApplicationId $application.Id -AppRoles (GetNewAppRoles)
    $wvdAdminRoleId = 'd1c2ade8-98f8-45fd-aa4a-6d06b947c66f'
    New-MgUserAppRoleAssignment -UserId $user.Id -PrincipalId $user.Id -ResourceId $servicePrincipal.Id -AppRoleId $wvdAdminRoleId

API のアクセス許可を設定する

以下の手順で API のアクセス許可を設定します。

API のアクセス許可を設定するには:
  1. Azureポータルで [Microsoft Entra ID] > [アプリの登録] > [すべてのアプリケーション] > [nerdio-nmw-app] (またはカスタムアプリ名) > [APIのアクセス許可] に移動します。

  2. Microsoft APIs > Microsoft Graph > Delegated permissions に、以下の権限を追加または確認します。

    • User.Read (既定で含まれます)

    • User.ReadBasic.All

    • User.Read.All

    • Group.Read.All

    • GroupMember.Read.All

    • Application.Read.All

    • Organization.Read.All

    • AppRoleAssignment.ReadWrite.All

    • Application.ReadWrite.All

    • Mail.Send (メール通知を有効にするためのオプション)

    • offline_access

    • openid

    • profile

  3. Microsoft APIs > Microsoft Graph > Application permissions に、以下の権限を追加します。

    • Group.Read.All

    • GroupMember.Read.All

    • Organization.Read.All

    • User.Read.All

  4. Microsoft APIs > Azure Service Management > Delegated permissions に、以下の権限を追加します。

    • user_impersonation

  5. (WVD Classicのみ) APIs my organization uses > Windows Virtual Desktop (アプリケーションID 5a0aa725-4958-4b0c-80a9-34562e23f3b7):

    • Delegated permissions(委任された権限)を追加します: user_impersonation

    • アプリケーションの権限を追加します:TenantCreator

  6. また、次の PowerShell スクリプトでも変更できます。

    $appName = "nerdio-nmw-app" # Optionally rename the default application
    $wvdClassicEnabled = $False # Optionally include permissions for WVD Classic
    $readDelagatedPermissions = "User.Read|User.ReadBasic.All|User.Read.All|Group.Read.All|GroupMember.Read.All|Application.Read.All|Organization.Read.All"
    Connect-MgGraph -Scopes "Application.ReadWrite.All"
    function GetResourceAccess($servicePrincipal, [string]$requiredPermissions, [string]$permissionType) {
        if ($permissionType -eq "Scope") {
            $exposedPermissions = $servicePrincipal.Oauth2PermissionScopes
        }
        else {
            $exposedPermissions = $servicePrincipal.AppRoles
        }
        foreach ($permission in $requiredPermissions.Trim().Split("|")) {
            $match = $exposedPermissions | Where-Object { $_.Value -eq $permission }
            if ($match) {
                @{ Id = $match.Id; Type = $permissionType }
            }
            else {
                Write-Warning "Permission '$permission' (type '$permissionType') was not found on '$($servicePrincipal.DisplayName)' and was skipped."
            }
        }
    }
    function GetRequiredPermissions([string] $applicationId, [string] $requiredDelegatedPermissions, [string]$requiredApplicationPermissions) {
        $sp = Get-MgServicePrincipal -Filter "appId eq '$applicationId'"
        if (-not $sp) {
            throw "No service principal found with application ID '$applicationId' in this tenant."
        }
        $resourceAccess = @()
        if ($requiredDelegatedPermissions) {
            $resourceAccess += @(GetResourceAccess $sp $requiredDelegatedPermissions "Scope")
        }
        if ($requiredApplicationPermissions) {
            $resourceAccess += @(GetResourceAccess $sp $requiredApplicationPermissions "Role")
        }
        return @{ ResourceAppId = $applicationId; ResourceAccess = $resourceAccess }
    }
    $application = Get-MgApplication -Filter "displayName eq '$appName'"
    if (-not $application) {
        throw "No application found with the display name '$appName'. Check that the app registration exists and the name matches exactly."
    }
    if (@($application).Count -gt 1) {
        throw "More than one application found with the display name '$appName'. Resolve this manually before continuing."
    }
    $graphPermissions = GetRequiredPermissions -applicationId "00000003-0000-0000-c000-000000000000" -requiredDelegatedPermissions "$readDelagatedPermissions|AppRoleAssignment.ReadWrite.All|Application.ReadWrite.All|offline_access|openid|profile|Mail.Send" -requiredApplicationPermissions "Group.Read.All|GroupMember.Read.All|Organization.Read.All|User.Read.All"
    if ($wvdClassicEnabled) {
        $wvdClassicPermissions = GetRequiredPermissions -applicationId "5a0aa725-4958-4b0c-80a9-34562e23f3b7" -requiredDelegatedPermissions "user_impersonation" -requiredApplicationPermissions "TenantCreator" # Required for WVD classic only
    }
    $rmPermissions = GetRequiredPermissions -applicationId "797f4846-ba00-4fd7-ba43-dac1f8f63013" -requiredDelegatedPermissions "user_impersonation" # Windows Azure Service Management API
    $requiredResourcesAccess = @($graphPermissions, $rmPermissions)
    if ($wvdClassicEnabled) {
        $requiredResourcesAccess += $wvdClassicPermissions # Required for WVD classic only
    }
    Update-MgApplication -ApplicationId $application.Id -RequiredResourceAccess $requiredResourcesAccess

サービスプリンシパルにサブスクリプション所有者ユーザーアカウントを所有者としてアサインします。

以下の手順で、サービスプリンシパルにサブスクリプション所有者ユーザーアカウントを所有者としてアサインします。

サブスクリプション所有者をアサインするには:
  1. Azure ポータルで、Microsoft Entra ID > エンタープライズ アプリケーション > すべてのアプリケーション > nerdio-nmw-app (またはカスタムアプリ名) > 所有者 > 追加 に移動します。

  2. Azure Marketplace から Nerdio Manager をデプロイし、インストールを完了しているユーザーアカウントを検索して、選択します。

  3. あるいは、以下の PowerShell スクリプトを使用してこれらの変更を完了することもできます。

    $userPrincipalName = "" # REQUIRED: Fill in UPN of subscription owner completing Nerdio Manager deployment
    $appName = "nerdio-nmw-app" # Optionally rename the default application
    Connect-MgGraph -Scopes "Application.ReadWrite.All","User.Read.All"
    $application = Get-MgApplication -Filter "displayName eq '$appName'"
    if (-not $application) {
        throw "No application found with the display name '$appName'. Check that the app registration exists and the name matches exactly."
    }
    if (@($application).Count -gt 1) {
        throw "More than one application found with the display name '$appName'. Resolve this manually before continuing."
    }
    $user = Get-MgUser -Filter "userPrincipalName eq '$userPrincipalName'"
    if (-not $user) {
        throw "No user found with the user principal name '$userPrincipalName'."
    }
    $servicePrincipal = Get-MgServicePrincipal -Filter "appId eq '$($application.AppId)'"
    New-MgServicePrincipalOwnerByRef -ServicePrincipalId $servicePrincipal.Id -BodyParameter @{ "@odata.id" = "https://graph.microsoft.com/v1.0/directoryObjects/$($user.Id)" }

管理者の同意を与える

以下の手順で管理者の同意を付与します。

管理者の同意を付与して
  1. Azure ポータルで Microsoft Entra ID > アプリケーションの登録 > すべてのアプリケーション > nerdio-nmw-app (またはカスタムアプリ名) > API のアクセス許可 に移動します。

  2. 「<tenant_name> に管理者の同意を付与する」を選択します。

  3. プロンプトが表示されたら、「組織の代わりに同意を付与する」を選択します。

  4. Microsoft Entra ID > エンタープライズ アプリケーション > すべてのアプリケーション > nerdio-nmw-app (またはカスタムアプリ名) > 権限 に移動します。

  5. 「<tenant_name> に管理者の同意を付与する」を選択します。

  6. プロンプトが表示されたら、「組織の代わりに同意を付与する」を選択します。

  7. あるいは、以下のPowerShellスクリプトでこれらの変更を完了します。

    注記

    このスクリプトは、サインインしているテナントを使用します。ブラウザーを開く代わりにリンクを表示するため、Azure Cloud Shellでも実行できます。Web ブラウザーでリンクを開き、グローバル管理者としてサインインして同意を付与してください。

    $appName = "nerdio-nmw-app" # Optionally rename the default application
    $microsoftLogin = 'https://login.microsoftonline.com'
    Connect-MgGraph -Scopes "Application.Read.All"
    $tenantId = (Get-MgContext).TenantId
    $application = Get-MgApplication -Filter "displayName eq '$appName'"
    if (-not $application) {
        throw "No application found with the display name '$appName'. Check that the app registration exists and the name matches exactly."
    }
    if (@($application).Count -gt 1) {
        throw "More than one application found with the display name '$appName'. Resolve this manually before continuing."
    }
    $consentUrl = "$microsoftLogin/$tenantId/adminconsent?client_id=$($application.AppId)"
    Write-Host "Open the following link in a web browser and sign in as a Global Administrator to grant admin consent:"
    Write-Host $consentUrl

1 つのスクリプトですべての手順を実行

上記のセクションを 1 つずつ進める代わりに、グローバル管理者、または特権ロール管理者とクラウド アプリケーション管理者の両方のロールを持つユーザーは、次のスクリプトを 1 回実行できます。これにより、アプリケーションとサービスプリンシパルの作成から 管理者の同意を付与するまでのすべての手順が完了します。アプリケーション シークレットは生成されません。そのセクションは別途完了してください。

すべての手順を 1 つのスクリプトで実行するには:
  1. PowerShell または Azure Cloud Shell を開いてください。

  2. 以下のスクリプトをコピーし、上部に必要な値を入力してください。

    • $webAppName:マーケットプレースの展開でプロビジョニングされた App Service の名前。

    • $userPrincipalName:Nerdio Manager の展開を完了するサブスクリプションの所有者のユーザー プリンシパル名 (UPN)。

    # ============================================
    # Create the Nerdio Manager application in Entra ID (advanced install)
    # ============================================
    # Run as a Global Administrator, or as a Privileged Role Administrator
    # combined with Cloud Application Administrator.
    # This script:
    # 1. Creates the application and a service principal.
    # 2. Configures the application roles and assigns the AVD admin.
    # 3. Configures the API permissions.
    # 4. Assigns the subscription owner as owner of the service principal.
    # 5. Displays the link for granting admin consent.
    # It does not generate the application secret.
    # ============================================
    
    # --- Settings ---
    $webAppName = "" # REQUIRED: Name of app service provisioned in marketplace deployment
    $userPrincipalName = "" # REQUIRED: UPN of the subscription owner completing the deployment
    $appName = "nerdio-nmw-app" # Optionally rename the default application
    $wvdClassicEnabled = $False # Optionally include permissions for WVD Classic
    $microsoftLogin = 'https://login.microsoftonline.com'
    $readDelagatedPermissions = "User.Read|User.ReadBasic.All|User.Read.All|Group.Read.All|GroupMember.Read.All|Application.Read.All|Organization.Read.All"
    
    # --- Sign in and check the settings before creating anything ---
    Connect-MgGraph -Scopes "Application.ReadWrite.All","AppRoleAssignment.ReadWrite.All","User.Read.All"
    $tenantId = (Get-MgContext).TenantId
    if (-not $webAppName -or -not $userPrincipalName) {
        throw "Fill in webAppName and userPrincipalName before running the script."
    }
    $user = Get-MgUser -Filter "userPrincipalName eq '$userPrincipalName'"
    if (-not $user) {
        throw "No user found with the user principal name '$userPrincipalName'."
    }
    if (Get-MgApplication -Filter "displayName eq '$appName'") {
        throw "An application named '$appName' already exists. Choose a different name or remove the existing application first."
    }
    
    # --- Step 1: Create the application and a service principal ---
    $webAppUrl = 'https://' + $webAppName + '.azurewebsites.net/'
    $loginUrl = $webAppUrl + 'signin-oidc'
    $logoutUrl = $webAppUrl + 'signout-oidc'
    $application = New-MgApplication -DisplayName $appName -SignInAudience "AzureADMyOrg" -Web @{
        HomePageUrl           = $webAppUrl
        LogoutUrl             = $logoutUrl
        RedirectUris          = @($webAppUrl, $loginUrl)
        ImplicitGrantSettings = @{ EnableAccessTokenIssuance = $false; EnableIdTokenIssuance = $false }
    }
    $servicePrincipal = New-MgServicePrincipal -AppId $application.AppId -AppRoleAssignmentRequired:$true -Tags @("WindowsAzureActiveDirectoryIntegratedApp")
    # Allow time for the new application and service principal to replicate
    Start-Sleep -Seconds 15
    
    # --- Step 2: Configure application roles and assign the AVD admin ---
    function BuildAppRole([string] $displayName, [string] $value, [Guid] $id, [string] $description) {
        return @{
            AllowedMemberTypes = @("User")
            Description        = $description
            DisplayName        = $displayName
            Id                 = $id
            IsEnabled          = $true
            Value              = $value
        }
    }
    function GetNewAppRoles() {
        $reviewer = BuildAppRole -displayName "Reviewer" -value "Reviewer" -id "0a1b7425-f55a-44a6-9caa-b9a5cc9448da" -description "View access to all areas of NMW; no ability to save or make changes."
        $helpDesk = BuildAppRole -displayName "Help Desk" -value "HelpDesk" -id "a94e83da-b314-4232-b8c8-94508c5ed533" -description "Complete access to User sessions only."
        $endUser = BuildAppRole -displayName "End-user" -value "EndUser" -id "e856de81-1e53-486a-8668-7d564866ae39" -description "View & manage own sessions (Message, Log off, Disconnect). Personal desktop users can restart, power off and power their personal desktops."
        $desktopAdmin = BuildAppRole -displayName "Desktop Admin" -value "DesktopAdmin" -id "ed0cdef0-4267-4470-bfff-5e0b6944f9e4" -description "Complete access to User sessions, ability to view Host Pools, hosts and restart them, but no ability to add/remove or change any settings."
        $wvdAdmin = BuildAppRole -displayName "WVD Admin" -value "WvdAdmin" -id 'd1c2ade8-98f8-45fd-aa4a-6d06b947c66f' -description "Complete access to all areas of NMW."
        return @($reviewer, $helpDesk, $endUser, $desktopAdmin, $wvdAdmin)
    }
    Update-MgApplication -ApplicationId $application.Id -AppRoles (GetNewAppRoles)
    $wvdAdminRoleId = 'd1c2ade8-98f8-45fd-aa4a-6d06b947c66f'
    New-MgUserAppRoleAssignment -UserId $user.Id -PrincipalId $user.Id -ResourceId $servicePrincipal.Id -AppRoleId $wvdAdminRoleId
    
    # --- Step 3: Configure API permissions ---
    function GetResourceAccess($servicePrincipal, [string]$requiredPermissions, [string]$permissionType) {
        if ($permissionType -eq "Scope") {
            $exposedPermissions = $servicePrincipal.Oauth2PermissionScopes
        }
        else {
            $exposedPermissions = $servicePrincipal.AppRoles
        }
        foreach ($permission in $requiredPermissions.Trim().Split("|")) {
            $match = $exposedPermissions | Where-Object { $_.Value -eq $permission }
            if ($match) {
                @{ Id = $match.Id; Type = $permissionType }
            }
            else {
                Write-Warning "Permission '$permission' (type '$permissionType') was not found on '$($servicePrincipal.DisplayName)' and was skipped."
            }
        }
    }
    function GetRequiredPermissions([string] $applicationId, [string] $requiredDelegatedPermissions, [string]$requiredApplicationPermissions) {
        $sp = Get-MgServicePrincipal -Filter "appId eq '$applicationId'"
        if (-not $sp) {
            throw "No service principal found with application ID '$applicationId' in this tenant."
        }
        $resourceAccess = @()
        if ($requiredDelegatedPermissions) {
            $resourceAccess += @(GetResourceAccess $sp $requiredDelegatedPermissions "Scope")
        }
        if ($requiredApplicationPermissions) {
            $resourceAccess += @(GetResourceAccess $sp $requiredApplicationPermissions "Role")
        }
        return @{ ResourceAppId = $applicationId; ResourceAccess = $resourceAccess }
    }
    $graphPermissions = GetRequiredPermissions -applicationId "00000003-0000-0000-c000-000000000000" -requiredDelegatedPermissions "$readDelagatedPermissions|AppRoleAssignment.ReadWrite.All|Application.ReadWrite.All|offline_access|openid|profile|Mail.Send" -requiredApplicationPermissions "Group.Read.All|GroupMember.Read.All|Organization.Read.All|User.Read.All"
    if ($wvdClassicEnabled) {
        $wvdClassicPermissions = GetRequiredPermissions -applicationId "5a0aa725-4958-4b0c-80a9-34562e23f3b7" -requiredDelegatedPermissions "user_impersonation" -requiredApplicationPermissions "TenantCreator" # Required for WVD classic only
    }
    $rmPermissions = GetRequiredPermissions -applicationId "797f4846-ba00-4fd7-ba43-dac1f8f63013" -requiredDelegatedPermissions "user_impersonation" # Windows Azure Service Management API
    $requiredResourcesAccess = @($graphPermissions, $rmPermissions)
    if ($wvdClassicEnabled) {
        $requiredResourcesAccess += $wvdClassicPermissions # Required for WVD classic only
    }
    Update-MgApplication -ApplicationId $application.Id -RequiredResourceAccess $requiredResourcesAccess
    
    # --- Step 4: Assign the subscription owner as owner of the service principal ---
    New-MgServicePrincipalOwnerByRef -ServicePrincipalId $servicePrincipal.Id -BodyParameter @{ "@odata.id" = "https://graph.microsoft.com/v1.0/directoryObjects/$($user.Id)" }
    
    # --- Step 5: Display the values to save and the admin consent link ---
    $consentUrl = "$microsoftLogin/$tenantId/adminconsent?client_id=$($application.AppId)"
    Write-Host "Application ID to be saved in to app service: $($application.AppId)"
    Write-Host "Service Principal ID to be provided to Nerdio Manager deployment: $($servicePrincipal.Id)"
    Write-Host "Open the following link in a web browser and sign in as a Global Administrator to grant admin consent:"
    Write-Host $consentUrl
  3. スクリプトを実行してください:

  4. スクリプトに表示されるアプリケーション ID とサービスプリンシパル ID を保存してください。(Nerdio Manager の展開用に提供してください。)

  5. スクリプトに表示されるリンクを Web ブラウザーで開き、グローバル管理者としてサインインして同意を付与してください。

    このスクリプトはブラウザーを開かずにリンクを表示するため、Azure Cloud Shell でも実行できます。

新しいアプリのクライアントシークレットを生成します (nerdio-nmw-app)

この手順は、グローバル管理者、または特権ロール管理者とクラウドアプリケーション管理者の組み合わせのユーザーの代わりに、サブスクリプションの所有者ユーザーが任意で完了できます。この場合、サブスクリプションの所有者ユーザーは、上記のエンタープライズアプリケーションのサービスプリンシパルに追加された所有者に加えて、アプリの登録の下にあるアプリの所有者として追加される必要があります。

新しいクライアントシークレットを生成するには:
  1. Microsoft Entra ID > アプリの登録 > すべてのアプリ > nerdio-nmw-app(またはカスタムアプリ名) > 証明書とシークレット > 新しいクライアントシークレットに移動します。

  2. 次の情報を入力してください。

    • 説明Nerdio Manager クライアントシークレット(オプション)

    • 有効期限カスタムを選択します。

      • 開始今日の日付を選択します。

      • 終了:これは、貴社のポリシーで許可されている最長の期間に設定する必要があります。

        注記

        Entra IDポータルでは、この値が最大2年に制限される場合があります。

  3. 生成されたシークレットの値を保存してください。

    注記

    これは、Azureポータルで(サブスクリプション所有者ユーザーによって)インストールを完了するために必要です。シークレットのIDではなく、値が使用されていることを確認してください。

  4. あるいは、以下のPowerShellスクリプトを使用してこれらの変更を完了することもできます。

    $appName = "nerdio-nmw-app" # Optionally rename the default application
    Connect-MgGraph -Scopes "Application.ReadWrite.All"
    $application = Get-MgApplication -Filter "displayName eq '$appName'"
    if (-not $application) {
        throw "No application found with the display name '$appName'. Check that the app registration exists and the name matches exactly."
    }
    if (@($application).Count -gt 1) {
        throw "More than one application found with the display name '$appName'. Resolve this manually before continuing."
    }
    $appSecret = Add-MgApplicationPassword -ApplicationId $application.Id -PasswordCredential @{ DisplayName = "Nerdio Manager Secret"; EndDateTime = (Get-Date).AddYears(10) }
    Write-Host "Application secret to be saved in Azure KeyVault: $($appSecret.SecretText)"

完了

AzureポータルでNerdio Managerのデプロイを完了するユーザー(サブスクリプション所有者)と、以下の値を共有してください:

  • アプリケーション ID:

  • アプリのクライアントシークレット(IDではなく、生成されたシークレットの値であることを確認してください。)

  • サービスプリンシパルID(これは、エンタープライズアプリケーションのアプリケーションのオブジェクトIDです。)

この記事は役に立ちましたか?

0人中0人がこの記事が役に立ったと言っています
他にご質問がございましたら、リクエストを送信してください

コメント (0件のコメント)

サインインしてコメントを残してください。