New-​Azure​Batch​Job

Creates a job in the Batch service.

Syntax

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

Description

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

Examples

Example 1: Create a job

PS C:\>$PoolInformation = New-Object -TypeName "Microsoft.Azure.Commands.Batch.Models.PSPoolInformation" 
PS C:\> $PoolInformation.PoolId = "Pool22" 
PS C:\> New-AzureBatchJob -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-AzureRmBatchAccountKeys cmdlet to assign a context to the $Context variable.

Required Parameters

-BatchContext

Specifies the BatchAccountContext instance that this cmdlet uses to interact with the Batch service. To obtain a BatchAccountContext object that contains access keys for your subscription, use the Get-AzureRmBatchAccountKeys cmdlet.

Type:BatchAccountContext
Position:Named
Default value:None
Accept pipeline input:True (ByValue)
Accept wildcard characters:False
-Id

Specifies an ID for the job.

Type:String
Position:0
Default value:None
Accept pipeline input:True (ByPropertyName)
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
Accept pipeline input:False
Accept wildcard characters:False

Optional Parameters

-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
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-Constraints

Specifies the execution constraints for the job.

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

Specifies the display name for the job.

Type:String
Position:Named
Default value:None
Accept pipeline input:False
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
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
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
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
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:OnAllTasksComplete
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-OnTaskFailure

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

Type:OnTaskFailure
Position:Named
Default value:None
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
Accept pipeline input:False
Accept wildcard characters:False
-UsesTaskDependencies
Type:SwitchParameter
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False