Editar

Partilhar via


New-AzBatchJob

Creates a job in the Batch service.

Syntax

New-AzBatchJob
   [-Id] <String>
   [-CommonEnvironmentSettings <IDictionary>]
   [-DisplayName <String>]
   [-Constraints <PSJobConstraints>]
   [-JobManagerTask <PSJobManagerTask>]
   [-JobPreparationTask <PSJobPreparationTask>]
   [-JobReleaseTask <PSJobReleaseTask>]
   [-Metadata <IDictionary>]
   -PoolInformation <PSPoolInformation>
   [-Priority <Int32>]
   [-UsesTaskDependencies]
   [-OnTaskFailure <OnTaskFailure>]
   [-OnAllTasksComplete <OnAllTasksComplete>]
   -BatchContext <BatchAccountContext>
   [-DefaultProfile <IAzureContextContainer>]
   [<CommonParameters>]

Description

The New-AzBatchJob cmdlet creates a job in the Azure Batch service in the account specified by the BatchAccountContext parameter.

Examples

Example 1: Create a job

$PoolInformation = New-Object -TypeName "Microsoft.Azure.Commands.Batch.Models.PSPoolInformation"
$PoolInformation.PoolId = "Pool22"
New-AzBatchJob -Id "ContosoJob35" -PoolInformation $PoolInformation -BatchContext $Context

The first command creates a PSPoolInformation object by using the New-Object cmdlet. The command stores that object in the $PoolInformation variable. The second command assigns the ID Pool22 to the PoolId property of the object in $PoolInformation. The final command creates a job that has the ID ContosoJob35. Tasks added to the job run on the pool that has the ID Pool22. Use the Get-AzBatchAccountKey cmdlet to assign a context to the $Context variable.

Parameters

-BatchContext

Specifies the BatchAccountContext instance that this cmdlet uses to interact with the Batch service. If you use the Get-AzBatchAccount cmdlet to get your BatchAccountContext, then Microsoft Entra authentication will be used when interacting with the Batch service. To use shared key authentication instead, use the Get-AzBatchAccountKey cmdlet to get a BatchAccountContext object with its access keys populated. When using shared key authentication, the primary access key is used by default. To change the key to use, set the BatchAccountContext.KeyInUse property.

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

-CommonEnvironmentSettings

Specifies the common environment variables, as key/value pairs, that this cmdlet sets for all tasks in the job. The key is the environment variable name. The value is the environment variable value.

Type:IDictionary
Aliases:CommonEnvironmentSetting
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Constraints

Specifies the execution constraints for the job.

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

-DefaultProfile

The credentials, account, tenant, and subscription used for communication with azure.

Type:IAzureContextContainer
Aliases:AzContext, AzureRmContext, AzureCredential
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-DisplayName

Specifies the display name for the job.

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

-Id

Specifies an ID for the job.

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

-JobManagerTask

Specifies the Job Manager task. The Batch service runs the Job Manager task when the job is started.

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

-JobPreparationTask

Specifies the Job Preparation task. The Batch service runs the Job Preparation task on a compute node before it starts any tasks of that job on that compute node.

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

-JobReleaseTask

Specifies the Job Release task. The Batch service runs the Job Release task when the job ends. The Batch service runs the Job Release task on each compute node where it ran any task of the job.

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

-Metadata

Specifies metadata, as key/value pairs, to add to the job. The key is the metadata name. The value is the metadata value.

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

-OnAllTasksComplete

Specifies an action the Batch service takes if all tasks in the job are in the completed state.

Type:Nullable<T>[OnAllTasksComplete]
Accepted values:NoAction, TerminateJob
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-OnTaskFailure

Specifies an action the Batch service takes if any task in the job fails.

Type:Nullable<T>[OnTaskFailure]
Accepted values:NoAction, PerformExitOptionsJobAction
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-PoolInformation

Specifies the details of the pool on which the Batch service runs the tasks of the job.

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

-Priority

Specifies the priority of the job. Valid values are: integers from -1000 to 1000. A value of -1000 is the lowest priority. A value of 1000 is the highest priority. The default value is 0.

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

-UsesTaskDependencies

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

Inputs

String

BatchAccountContext

Outputs

Void