Upravit

Sdílet prostřednictvím


Start-AzAksManagedClusterCommand

AKS will create a pod to run the command. This is primarily useful for private clusters. For more information see AKS Run Command.

Syntax

Start-AzAksManagedClusterCommand
     -ResourceGroupName <String>
     -ResourceName <String>
     [-SubscriptionId <String>]
     -Command <String>
     [-ClusterToken <String>]
     [-Context <String>]
     [-DefaultProfile <PSObject>]
     [-AsJob]
     [-NoWait]
     [-WhatIf]
     [-Confirm]
     [<CommonParameters>]
Start-AzAksManagedClusterCommand
     -InputObject <IAksIdentity>
     -Command <String>
     [-ClusterToken <String>]
     [-Context <String>]
     [-DefaultProfile <PSObject>]
     [-AsJob]
     [-NoWait]
     [-WhatIf]
     [-Confirm]
     [<CommonParameters>]

Description

AKS will create a pod to run the command. This is primarily useful for private clusters. For more information see AKS Run Command.

Examples

Example 1: Run AKS command

Start-AzAksManagedClusterCommand -ResourceGroupName mygroup -ResourceName mycluster -Command "kubectl get nodes"

ExitCode          : 0
FinishedAt        : 3/31/2023 8:52:17 AM
Id                : 0a3991475d9744fcbfdc2595b40e517f
Log               : NAME                              STATUS   ROLES   AGE   VERSION
                    aks-default-40136599-vmss000000   Ready    agent   46m   v1.24.9
                    aks-pool2-22198594-vmss000000     Ready    agent   43m   v1.24.9

ProvisioningState : Succeeded
Reason            :
StartedAt         : 3/31/2023 8:52:16 AM

AKS will create a pod to run the command. This is primarily useful for private clusters.

Example 2: Run AKS command via identity

$cluster = Get-AzAksCluster -ResourceGroupName mygroup -Name mycluster
$cluster | Start-AzAksManagedClusterCommand -Command "kubectl get nodes"

ExitCode          : 0
FinishedAt        : 3/31/2023 8:54:17 AM
Id                : 0a3991475d9744fcbfdc2595b40e517f
Log               : NAME                              STATUS   ROLES   AGE   VERSION
                    aks-default-40136599-vmss000000   Ready    agent   46m   v1.24.9
                    aks-pool2-22198594-vmss000000     Ready    agent   43m   v1.24.9

ProvisioningState : Succeeded
Reason            :
StartedAt         : 3/31/2023 8:54:16 AM

Parameters

-AsJob

Run the command as a job

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

-ClusterToken

AuthToken issued for AKS AAD Server App.

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

-Command

The command to run.

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

-Confirm

Prompts you for confirmation before running the cmdlet.

Type:SwitchParameter
Aliases:cf
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Context

A base64 encoded zip file containing the files required by the command.

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

-DefaultProfile

The DefaultProfile parameter is not functional. Use the SubscriptionId parameter when available if executing the cmdlet against a different subscription.

Type:PSObject
Aliases:AzureRMContext, AzureCredential
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-InputObject

Identity Parameter To construct, see NOTES section for INPUTOBJECT properties and create a hash table.

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

-NoWait

Run the command asynchronously

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

-ResourceGroupName

The name of the resource group. The name is case insensitive.

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

-ResourceName

The name of the managed cluster resource.

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

-SubscriptionId

The ID of the target subscription.

Type:String
Position:Named
Default value:(Get-AzContext).Subscription.Id
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Type:SwitchParameter
Aliases:wi
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

Inputs

IAksIdentity

Outputs

IRunCommandResult