< Back
New-AzureBatchTask
Post
NAME New-AzureBatchTask
SYNOPSIS
Creates a Batch task under a job.
SYNTAX
New-AzureBatchTask [-AffinityInformation <PSAffinityInformation>] [-ApplicationPackageReferences <PSApplicationPackageReference[]>]
[-AuthenticationTokenSettings <PSAuthenticationTokenSettings>] -BatchContext <BatchAccountContext> [-CommandLine <String>] [-Constraints
<PSTaskConstraints>] [-ContainerSettings <PSTaskContainerSettings>] [-DefaultProfile <IAzureContextContainer>] [-DependsOn <TaskDependencies>]
[-DisplayName <String>] [-EnvironmentSettings <IDictionary>] [-ExitConditions <PSExitConditions>] -Id <String> -JobId <String>
[-MultiInstanceSettings <PSMultiInstanceSettings>] [-OutputFile <PSOutputFile[]>] [-ResourceFiles <IDictionary>] [-UserIdentity <PSUserIdentity>]
[<CommonParameters>]
New-AzureBatchTask [-AffinityInformation <PSAffinityInformation>] [-ApplicationPackageReferences <PSApplicationPackageReference[]>]
[-AuthenticationTokenSettings <PSAuthenticationTokenSettings>] -BatchContext <BatchAccountContext> [-CommandLine <String>] [-Constraints
<PSTaskConstraints>] [-ContainerSettings <PSTaskContainerSettings>] [-DefaultProfile <IAzureContextContainer>] [-DependsOn <TaskDependencies>]
[-DisplayName <String>] [-EnvironmentSettings <IDictionary>] [-ExitConditions <PSExitConditions>] -Id <String> [-Job <PSCloudJob>]
[-MultiInstanceSettings <PSMultiInstanceSettings>] [-OutputFile <PSOutputFile[]>] [-ResourceFiles <IDictionary>] [-UserIdentity <PSUserIdentity>]
[<CommonParameters>]
New-AzureBatchTask -BatchContext <BatchAccountContext> [-DefaultProfile <IAzureContextContainer>] [-Job <PSCloudJob>] [-Tasks <PSCloudTask[]>]
[<CommonParameters>]
New-AzureBatchTask -BatchContext <BatchAccountContext> [-DefaultProfile <IAzureContextContainer>] -JobId <String> [-Tasks <PSCloudTask[]>]
[<CommonParameters>]
DESCRIPTION
The New-AzureBatchTask cmdlet creates an Azure Batch task under the job specified by the JobId parameter or the Job parameter.
PARAMETERS
-AffinityInformation <PSAffinityInformation>
Specifies a locality hint that the Batch service uses to select a node on which to run the task.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-ApplicationPackageReferences <PSApplicationPackageReference[]>
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-AuthenticationTokenSettings <PSAuthenticationTokenSettings>
The settings for an authentication token that the task can use to perform Batch service operations.
If this is set, the Batch service provides the task with an authentication token which can be used to authenticate Batch service operations
without requiring an account access key. The token is provided via the AZ_BATCH_AUTHENTICATION_TOKEN environment variable. The operations
that the task can carry out using the token depend on the settings. For example, a task can request job permissions in order to add other
tasks to the job, or check the status of the job or of other tasks.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-BatchContext <BatchAccountContext>
Specifies the BatchAccountContext instance that this cmdlet uses to interact with the Batch service. If you use the Get-AzureRmBatchAccount
cmdlet to get your BatchAccountContext, then Azure Active Directory authentication will be used when interacting with the Batch service. To
use shared key authentication instead, use the Get-AzureRmBatchAccountKeys 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.
Required? true
Position? named
Default value None
Accept pipeline input? True (ByValue)
Accept wildcard characters? false
-CommandLine <String>
Specifies the command line for the task.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-Constraints <PSTaskConstraints>
Specifies the execution constraints that apply to this task.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-ContainerSettings <PSTaskContainerSettings>
The settings for the container under which the task runs.
If the pool that will run this task has containerConfiguration set, this must be set as well. If the pool that will run this task doesn't have
containerConfiguration set, this must not be set. When this is specified, all directories recursively below the AZ_BATCH_NODE_ROOT_DIR (the
root of Azure Batch directories on the node) are mapped into the container, all task environment variables are mapped into the container, and
the task command line is executed in the container.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-DefaultProfile <IAzureContextContainer>
The credentials, account, tenant, and subscription used for communication with azure.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-DependsOn <TaskDependencies>
Specifies that the task depends on other tasks. The task will not be scheduled until all depended-on tasks have completed successfully.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-DisplayName <String>
Specifies the display name of the task.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-EnvironmentSettings <IDictionary>
Specifies the environment settings, as key/value pairs, that this cmdlet adds to the task. The key is the environment setting name. The value
is the environment setting.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-ExitConditions <PSExitConditions>
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-Id <String>
Specifies the ID of the task.
Required? true
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-Job <PSCloudJob>
Specifies the job under which this cmdlet creates the task. To obtain a PSCloudJob object, use the Get-AzureBatchJob cmdlet.
Required? false
Position? named
Default value None
Accept pipeline input? True (ByValue)
Accept wildcard characters? false
-JobId <String>
Specifies the ID of the job under which this cmdlet creates the task.
Required? true
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-MultiInstanceSettings <PSMultiInstanceSettings>
Specifies information about how to run a multi-instance task.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-OutputFile <PSOutputFile[]>
Gets or sets a list of files that the Batch service will upload from the compute node after running the command line.
For multi-instance tasks, the files will only be uploaded from the compute node on which the primary task is executed.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-ResourceFiles <IDictionary>
Specifies resource files, as key/value pairs, that the task requires. The key is the resource file path. The value is the resource file blob
source.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-Tasks <PSCloudTask[]>
Specifies the collection of tasks to be added. Each task must have a unique ID.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-UserIdentity <PSUserIdentity>
The user identity under which the task runs.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
BatchAccountContext
Parameter 'BatchContext' accepts value of type 'BatchAccountContext' from the pipeline
PSCloudJob
Parameter 'Job' accepts value of type 'PSCloudJob' from the pipeline
OUTPUTS
NOTES
Example 1: Create a Batch task
PS C:\\>New-AzureBatchTask -JobId "Job-000001" -Id "Task23" -CommandLine "cmd /c dir /s" -BatchContext $Context
This command creates a task that has the ID Task23 under the job that has the ID Job-000001. The task runs the specified command. Use the
Get-AzureRmBatchAccountKeys cmdlet to assign a context to the $Context variable.
Example 2: Create a Batch task
PS C:\\> $autoUser = New-Object Microsoft.Azure.Commands.Batch.Models.PSAutoUserSpecification -ArgumentList @("Task", "Admin")
PS C:\\> $userIdentity = New-Object Microsoft.Azure.Commands.Batch.Models.PSUserIdentity $autoUser
PS C:\\>Get-AzureBatchJob -Id "Job-000001" -BatchContext $Context | New-AzureBatchTask -Id "Task26" -CommandLine "cmd /c echo hello > newFile.txt"
-UserIdentity $userIdentity -BatchContext $Context
This command gets the Batch job that has the ID Job-000001 by using the Get-AzureBatchJob cmdlet. The command passes that job to the current
cmdlet by using the pipeline operator. The command creates a task that has the ID Task26 under that job. The task runs the specified command by
using elevated permissions.
Example 3: Add a collection of tasks to the specified job by using the pipeline
PS C:\\>$Context = Get-AzureRmBatchAccountKeys -AccountName "ContosoBatchAccount"
PS C:\\> $Task01 = New-Object Microsoft.Azure.Commands.Batch.Models.PSCloudTask("Task23", "cmd /c dir /s")
PS C:\\> $Task02 = New-Object Microsoft.Azure.Commands.Batch.Models.PSCloudTask("Task24", "cmd /c dir /s")
PS C:\\> Get-AzureBatchJob -Id "Job-000001" -BatchContext $Context | New-AzureBatchTask -Tasks @($Task01, $Task02) -BatchContext $Context
The first command creates an object reference to the account keys for the batch account named ContosoBatchAccount by using
Get-AzureRmBatchAccountKeys . The command stores this object reference in the $Context variable.
The next two commands create PSCloudTask objects by using the New-Object cmdlet. The commands store the tasks in the $Task01 and $Task02 variables.
The final command gets the Batch job that has the ID Job-000001 by using Get-AzureBatchJob . Then the command passes that job to the current
cmdlet by using the pipeline operator. The command adds a collection of tasks under that job. The command uses the context stored in $Context.
Example 4: Add a collection of tasks to the specified job
PS C:\\>$Context = Get-AzureRmBatchAccountKeys -AccountName "ContosoBatchAccount"
PS C:\\> $Task01 = New-Object Microsoft.Azure.Commands.Batch.Models.PSCloudTask("Task23", "cmd /c dir /s")
PS C:\\> $Task02 = New-Object Microsoft.Azure.Commands.Batch.Models.PSCloudTask("Task24", "cmd /c dir /s")
PS C:\\> New-AzureBatchTask -JobId "Job-000001" -Tasks @($Task01, $Task02) -BatchContext $Context
The first command creates an object reference to the account keys for the batch account named ContosoBatchAccount by using
Get-AzureRmBatchAccountKeys . The command stores this object reference in the $Context variable.
The next two commands create PSCloudTask objects by using the New-Object cmdlet. The commands store the tasks in the $Task01 and $Task02 variables.
The final command adds the tasks stored in $Task01 and $Task02 under the job that has the ID Job-000001.
Example 5: Add a task with output files
PS C:\\>New-AzureBatchTask -JobId "Job-000001" -Id "Task23" -CommandLine "cmd /c dir /s" -BatchContext $Context
PS C:\\>$blobContainerDestination = New-Object Microsoft.Azure.Commands.Batch.Models.PSOutputFileBlobContainerDestination "https://myaccount.blob.co
re.windows.net/sascontainer?sv=2015-04-05&st=2015-04-29T22%3A18%3A26Z&se=2015-04-30T02%3A23%3A26Z&sr=b&sp=rw&spr=https&sig=Z%2FRHIX5Xcg0Mq2rqI3OlWT
jEg2tYkboXr1P9ZUXDtkk%3D"
PS C:\\>$destination = New-Object Microsoft.Azure.Commands.Batch.Models.PSOutputFileDestination $blobContainerDestination
PS C:\\>$uploadOptions = New-Object Microsoft.Azure.Commands.Batch.Models.PSOutputFileUploadOptions "TaskSuccess"
PS C:\\>$outputFile = New-Object Microsoft.Azure.Commands.Batch.Models.PSOutputFile "*.txt", $blobContainerDestination, $uploadOptions
PS C:\\>New-AzureBatchTask -JobId "Job-000001" -Id "Task23" -CommandLine "cmd /c dir /s" -OutputFile $outputFile -BatchContext $Context
Example 6: Add a task with authentication token settings
PS C:\\>$authSettings = New-Object Microsoft.Azure.Commands.Batch.Models.PSAuthenticationTokenSettings
PS C:\\>$authSettings.Access = "Job"
PS C:\\>New-AzureBatchTask -JobId "Job-000001" -Id "Task23" -CommandLine "cmd /c dir /s" -AuthenticationTokenSettings $authSettings -BatchContext
$Context
Example 7: Add a task which runs in a container
PS C:\\>New-AzureBatchTask -JobId "Job-000001" -Id "Task23" -CommandLine "cmd /c dir /s" -ContainerSettings New-Object
Microsoft.Azure.Commands.Batch.Models.PSTaskContainerSettings "containerImageName"
RELATED LINKS
Online Version: https://docs.microsoft.com/en-us/powers ... ebatchtask
Get-AzureRmBatchAccountKeys
Get-AzureBatchJob
Get-AzureBatchTask
New-AzureBatchTask
Remove-AzureBatchTask
Stop-AzureBatchTask
Azure Batch Cmdlets
SYNOPSIS
Creates a Batch task under a job.
SYNTAX
New-AzureBatchTask [-AffinityInformation <PSAffinityInformation>] [-ApplicationPackageReferences <PSApplicationPackageReference[]>]
[-AuthenticationTokenSettings <PSAuthenticationTokenSettings>] -BatchContext <BatchAccountContext> [-CommandLine <String>] [-Constraints
<PSTaskConstraints>] [-ContainerSettings <PSTaskContainerSettings>] [-DefaultProfile <IAzureContextContainer>] [-DependsOn <TaskDependencies>]
[-DisplayName <String>] [-EnvironmentSettings <IDictionary>] [-ExitConditions <PSExitConditions>] -Id <String> -JobId <String>
[-MultiInstanceSettings <PSMultiInstanceSettings>] [-OutputFile <PSOutputFile[]>] [-ResourceFiles <IDictionary>] [-UserIdentity <PSUserIdentity>]
[<CommonParameters>]
New-AzureBatchTask [-AffinityInformation <PSAffinityInformation>] [-ApplicationPackageReferences <PSApplicationPackageReference[]>]
[-AuthenticationTokenSettings <PSAuthenticationTokenSettings>] -BatchContext <BatchAccountContext> [-CommandLine <String>] [-Constraints
<PSTaskConstraints>] [-ContainerSettings <PSTaskContainerSettings>] [-DefaultProfile <IAzureContextContainer>] [-DependsOn <TaskDependencies>]
[-DisplayName <String>] [-EnvironmentSettings <IDictionary>] [-ExitConditions <PSExitConditions>] -Id <String> [-Job <PSCloudJob>]
[-MultiInstanceSettings <PSMultiInstanceSettings>] [-OutputFile <PSOutputFile[]>] [-ResourceFiles <IDictionary>] [-UserIdentity <PSUserIdentity>]
[<CommonParameters>]
New-AzureBatchTask -BatchContext <BatchAccountContext> [-DefaultProfile <IAzureContextContainer>] [-Job <PSCloudJob>] [-Tasks <PSCloudTask[]>]
[<CommonParameters>]
New-AzureBatchTask -BatchContext <BatchAccountContext> [-DefaultProfile <IAzureContextContainer>] -JobId <String> [-Tasks <PSCloudTask[]>]
[<CommonParameters>]
DESCRIPTION
The New-AzureBatchTask cmdlet creates an Azure Batch task under the job specified by the JobId parameter or the Job parameter.
PARAMETERS
-AffinityInformation <PSAffinityInformation>
Specifies a locality hint that the Batch service uses to select a node on which to run the task.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-ApplicationPackageReferences <PSApplicationPackageReference[]>
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-AuthenticationTokenSettings <PSAuthenticationTokenSettings>
The settings for an authentication token that the task can use to perform Batch service operations.
If this is set, the Batch service provides the task with an authentication token which can be used to authenticate Batch service operations
without requiring an account access key. The token is provided via the AZ_BATCH_AUTHENTICATION_TOKEN environment variable. The operations
that the task can carry out using the token depend on the settings. For example, a task can request job permissions in order to add other
tasks to the job, or check the status of the job or of other tasks.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-BatchContext <BatchAccountContext>
Specifies the BatchAccountContext instance that this cmdlet uses to interact with the Batch service. If you use the Get-AzureRmBatchAccount
cmdlet to get your BatchAccountContext, then Azure Active Directory authentication will be used when interacting with the Batch service. To
use shared key authentication instead, use the Get-AzureRmBatchAccountKeys 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.
Required? true
Position? named
Default value None
Accept pipeline input? True (ByValue)
Accept wildcard characters? false
-CommandLine <String>
Specifies the command line for the task.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-Constraints <PSTaskConstraints>
Specifies the execution constraints that apply to this task.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-ContainerSettings <PSTaskContainerSettings>
The settings for the container under which the task runs.
If the pool that will run this task has containerConfiguration set, this must be set as well. If the pool that will run this task doesn't have
containerConfiguration set, this must not be set. When this is specified, all directories recursively below the AZ_BATCH_NODE_ROOT_DIR (the
root of Azure Batch directories on the node) are mapped into the container, all task environment variables are mapped into the container, and
the task command line is executed in the container.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-DefaultProfile <IAzureContextContainer>
The credentials, account, tenant, and subscription used for communication with azure.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-DependsOn <TaskDependencies>
Specifies that the task depends on other tasks. The task will not be scheduled until all depended-on tasks have completed successfully.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-DisplayName <String>
Specifies the display name of the task.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-EnvironmentSettings <IDictionary>
Specifies the environment settings, as key/value pairs, that this cmdlet adds to the task. The key is the environment setting name. The value
is the environment setting.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-ExitConditions <PSExitConditions>
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-Id <String>
Specifies the ID of the task.
Required? true
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-Job <PSCloudJob>
Specifies the job under which this cmdlet creates the task. To obtain a PSCloudJob object, use the Get-AzureBatchJob cmdlet.
Required? false
Position? named
Default value None
Accept pipeline input? True (ByValue)
Accept wildcard characters? false
-JobId <String>
Specifies the ID of the job under which this cmdlet creates the task.
Required? true
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-MultiInstanceSettings <PSMultiInstanceSettings>
Specifies information about how to run a multi-instance task.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-OutputFile <PSOutputFile[]>
Gets or sets a list of files that the Batch service will upload from the compute node after running the command line.
For multi-instance tasks, the files will only be uploaded from the compute node on which the primary task is executed.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-ResourceFiles <IDictionary>
Specifies resource files, as key/value pairs, that the task requires. The key is the resource file path. The value is the resource file blob
source.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-Tasks <PSCloudTask[]>
Specifies the collection of tasks to be added. Each task must have a unique ID.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-UserIdentity <PSUserIdentity>
The user identity under which the task runs.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
BatchAccountContext
Parameter 'BatchContext' accepts value of type 'BatchAccountContext' from the pipeline
PSCloudJob
Parameter 'Job' accepts value of type 'PSCloudJob' from the pipeline
OUTPUTS
NOTES
Example 1: Create a Batch task
PS C:\\>New-AzureBatchTask -JobId "Job-000001" -Id "Task23" -CommandLine "cmd /c dir /s" -BatchContext $Context
This command creates a task that has the ID Task23 under the job that has the ID Job-000001. The task runs the specified command. Use the
Get-AzureRmBatchAccountKeys cmdlet to assign a context to the $Context variable.
Example 2: Create a Batch task
PS C:\\> $autoUser = New-Object Microsoft.Azure.Commands.Batch.Models.PSAutoUserSpecification -ArgumentList @("Task", "Admin")
PS C:\\> $userIdentity = New-Object Microsoft.Azure.Commands.Batch.Models.PSUserIdentity $autoUser
PS C:\\>Get-AzureBatchJob -Id "Job-000001" -BatchContext $Context | New-AzureBatchTask -Id "Task26" -CommandLine "cmd /c echo hello > newFile.txt"
-UserIdentity $userIdentity -BatchContext $Context
This command gets the Batch job that has the ID Job-000001 by using the Get-AzureBatchJob cmdlet. The command passes that job to the current
cmdlet by using the pipeline operator. The command creates a task that has the ID Task26 under that job. The task runs the specified command by
using elevated permissions.
Example 3: Add a collection of tasks to the specified job by using the pipeline
PS C:\\>$Context = Get-AzureRmBatchAccountKeys -AccountName "ContosoBatchAccount"
PS C:\\> $Task01 = New-Object Microsoft.Azure.Commands.Batch.Models.PSCloudTask("Task23", "cmd /c dir /s")
PS C:\\> $Task02 = New-Object Microsoft.Azure.Commands.Batch.Models.PSCloudTask("Task24", "cmd /c dir /s")
PS C:\\> Get-AzureBatchJob -Id "Job-000001" -BatchContext $Context | New-AzureBatchTask -Tasks @($Task01, $Task02) -BatchContext $Context
The first command creates an object reference to the account keys for the batch account named ContosoBatchAccount by using
Get-AzureRmBatchAccountKeys . The command stores this object reference in the $Context variable.
The next two commands create PSCloudTask objects by using the New-Object cmdlet. The commands store the tasks in the $Task01 and $Task02 variables.
The final command gets the Batch job that has the ID Job-000001 by using Get-AzureBatchJob . Then the command passes that job to the current
cmdlet by using the pipeline operator. The command adds a collection of tasks under that job. The command uses the context stored in $Context.
Example 4: Add a collection of tasks to the specified job
PS C:\\>$Context = Get-AzureRmBatchAccountKeys -AccountName "ContosoBatchAccount"
PS C:\\> $Task01 = New-Object Microsoft.Azure.Commands.Batch.Models.PSCloudTask("Task23", "cmd /c dir /s")
PS C:\\> $Task02 = New-Object Microsoft.Azure.Commands.Batch.Models.PSCloudTask("Task24", "cmd /c dir /s")
PS C:\\> New-AzureBatchTask -JobId "Job-000001" -Tasks @($Task01, $Task02) -BatchContext $Context
The first command creates an object reference to the account keys for the batch account named ContosoBatchAccount by using
Get-AzureRmBatchAccountKeys . The command stores this object reference in the $Context variable.
The next two commands create PSCloudTask objects by using the New-Object cmdlet. The commands store the tasks in the $Task01 and $Task02 variables.
The final command adds the tasks stored in $Task01 and $Task02 under the job that has the ID Job-000001.
Example 5: Add a task with output files
PS C:\\>New-AzureBatchTask -JobId "Job-000001" -Id "Task23" -CommandLine "cmd /c dir /s" -BatchContext $Context
PS C:\\>$blobContainerDestination = New-Object Microsoft.Azure.Commands.Batch.Models.PSOutputFileBlobContainerDestination "https://myaccount.blob.co
re.windows.net/sascontainer?sv=2015-04-05&st=2015-04-29T22%3A18%3A26Z&se=2015-04-30T02%3A23%3A26Z&sr=b&sp=rw&spr=https&sig=Z%2FRHIX5Xcg0Mq2rqI3OlWT
jEg2tYkboXr1P9ZUXDtkk%3D"
PS C:\\>$destination = New-Object Microsoft.Azure.Commands.Batch.Models.PSOutputFileDestination $blobContainerDestination
PS C:\\>$uploadOptions = New-Object Microsoft.Azure.Commands.Batch.Models.PSOutputFileUploadOptions "TaskSuccess"
PS C:\\>$outputFile = New-Object Microsoft.Azure.Commands.Batch.Models.PSOutputFile "*.txt", $blobContainerDestination, $uploadOptions
PS C:\\>New-AzureBatchTask -JobId "Job-000001" -Id "Task23" -CommandLine "cmd /c dir /s" -OutputFile $outputFile -BatchContext $Context
Example 6: Add a task with authentication token settings
PS C:\\>$authSettings = New-Object Microsoft.Azure.Commands.Batch.Models.PSAuthenticationTokenSettings
PS C:\\>$authSettings.Access = "Job"
PS C:\\>New-AzureBatchTask -JobId "Job-000001" -Id "Task23" -CommandLine "cmd /c dir /s" -AuthenticationTokenSettings $authSettings -BatchContext
$Context
Example 7: Add a task which runs in a container
PS C:\\>New-AzureBatchTask -JobId "Job-000001" -Id "Task23" -CommandLine "cmd /c dir /s" -ContainerSettings New-Object
Microsoft.Azure.Commands.Batch.Models.PSTaskContainerSettings "containerImageName"
RELATED LINKS
Online Version: https://docs.microsoft.com/en-us/powers ... ebatchtask
Get-AzureRmBatchAccountKeys
Get-AzureBatchJob
Get-AzureBatchTask
New-AzureBatchTask
Remove-AzureBatchTask
Stop-AzureBatchTask
Azure Batch Cmdlets