Edit

Share via


New-AzBatchJob

Creates a job in the Batch service.

Syntax

Default (Default)

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.

Parameter properties

Type:BatchAccountContext
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:True
Value from pipeline:True
Value from pipeline by property name:False
Value from remaining arguments: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.

Parameter properties

Type:IDictionary
Default value:None
Supports wildcards:False
DontShow:False
Aliases:CommonEnvironmentSetting

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Constraints

Specifies the execution constraints for the job.

Parameter properties

Type:PSJobConstraints
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-DefaultProfile

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

Parameter properties

Type:IAzureContextContainer
Default value:None
Supports wildcards:False
DontShow:False
Aliases:AzContext, AzureRmContext, AzureCredential

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-DisplayName

Specifies the display name for the job.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Id

Specifies an ID for the job.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:0
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-JobManagerTask

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

Parameter properties

Type:PSJobManagerTask
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments: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.

Parameter properties

Type:PSJobPreparationTask
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments: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.

Parameter properties

Type:PSJobReleaseTask
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments: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.

Parameter properties

Type:IDictionary
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-OnAllTasksComplete

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

Parameter properties

Type:

Nullable<T>[OnAllTasksComplete]

Default value:None
Accepted values:NoAction, TerminateJob
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-OnTaskFailure

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

Parameter properties

Type:

Nullable<T>[OnTaskFailure]

Default value:None
Accepted values:NoAction, PerformExitOptionsJobAction
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-PoolInformation

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

Parameter properties

Type:PSPoolInformation
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments: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.

Parameter properties

Type:Int32
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-UsesTaskDependencies

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

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

Inputs

String

BatchAccountContext

Outputs

Void