次の方法で共有


Set-AksHciRegistration

概要

AKS ハイブリッドを Azure に登録します。

構文

Set-AksHciRegistration -subscriptionId<String>
                       -resourceGroupName <String>
                      [-tenantId <String>]
                      [-armAccessToken <String>]
                      [-graphAccessToken <String>]
                      [-accountId <String>]
                      [-environmentName <String>]
                      [-credential <PSCredential>]
                      [-region <String>]
                      [-useDeviceAuthentication]
                      [-skipLogin]

形容

AKS ハイブリッドを Azure に登録します。

サブスクリプション ID とリソース グループ名を使用して AKS ハイブリッドを登録する

Set-AksHciRegistration -subscriptionId aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e -resourceGroupName myresourcegroup

デバイス ログインに登録するか、ヘッドレス シェルで実行中に登録する

Set-AksHciRegistration -subscriptionId myazuresubscription -resourceGroupName myresourcegroup -UseDeviceAuthentication

サービス プリンシパルを使用して AKS ハイブリッドを登録する

"所有者" であるサブスクリプションにアクセスできない場合は、サービス プリンシパルを使用して課金のために AKS ホストを Azure に登録できます。

Connect-AzAccount PowerShell コマンドを使用して Azure にログインします。

Connect-AzAccount

Set-AzContext コマンドを実行して、課金対象の AKS ホストを既定のサブスクリプションとして登録するために使用するサブスクリプションを設定します。

Set-AzContext -Subscription myAzureSubscription

Get-AzContext PowerShell コマンドを実行して、ログイン コンテキストが正しいことを確認します。 サブスクリプション、テナント、アカウントが、課金のために AKS ホストを登録するために使用する内容であることを確認します。

Get-AzContext
Name                                     Account                      SubscriptionName             Environment                  TenantId
----                                     -------                      ----------------             -----------                  --------
myAzureSubscription (92391anf-...        user@contoso.com             myAzureSubscription          AzureCloud                   xxxxxx-xxxx-xxxx-xxxxxx

テナント ID を取得します。

$tenant = (Get-AzContext).Tenant.Id

New-AzADServicePrincipal PowerShell コマンドを実行して、サービス プリンシパルを作成します。 このコマンドは、"共同作成者" ロールを持つサービス プリンシパルを作成し、サブスクリプション レベルでスコープを設定します。 サービス プリンシパルの作成の詳細については、「Azure PowerShellを使用して Azure サービス プリンシパルを作成する」を参照してください。

$sp = New-AzADServicePrincipal -Role "Contributor" -Scope "/subscriptions/myazuresubscription"

次のコマンドを実行して、サービス プリンシパルのパスワードを取得します。

$secret = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($sp.Secret))
Write-Host "Application ID: $($sp.ApplicationId)"
Write-Host "App Secret: $secret"

上記の出力から、AKS ハイブリッドのデプロイ時に アプリケーション IDシークレット 使用できるようになりました。 これらの項目をメモし、安全に保存する必要があります。 アプリケーション ID とシークレットが使用可能になったので、Azure portalサブスクリプションアクセス制御、およびロールの割り当てのを すると、新しいサービス プリンシパルが表示されます。

Get-Credentialを使用してサービス プリンシパルの資格情報 (アプリケーション ID とシークレット) を 保存し、登録を設定します。

$credential = Get-Credential
Set-AksHciRegistration -SubscriptionId myazuresubscription -ResourceGroupName myresourcegroup -TenantId $tenant -Credential $credential

パラメーター

-subscriptionId

使用する Azure サブスクリプションの ID。

Type: System.String
Parameter Sets: (All)
Aliases:

Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-resourceGroupName

Arc リソースを配置するリソース グループの名前。

Type: System.String
Parameter Sets: (All)
Aliases:

Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-tenantId

Azure サービス プリンシパルのテナント ID。

Type: System.String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-armAccessToken

Azure Resource Manager にアクセスするためのトークン。

Type: System.String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-graphAccessToken

グラフにアクセスするためのトークン。

Type: System.String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-accountId

Azure アカウントの ID。

Type: System.String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: 1
Accept pipeline input: False
Accept wildcard characters: False

-environmentName

目的のパブリック クラウドの名前。

Type: System.String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-資格 情報

ユーザーのサービス プリンシパルを保持する PSCredential。

Type: System.String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-地域

Azure の場所。

Type: System.String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-useDeviceAuthentication

ブラウザーで使用するコードを出力します。

Type: System.String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-skipLogin

Connect-AzAccount 呼び出しをスキップします。 このフラグは、オートメーションで、または接続されたシェルから実行する場合に便利です。

Type: System.String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

次の手順

AksHci PowerShell リファレンス