Bulk delete all the old jobs from the batch account by info.odysseyx@gmail.com August 22, 2024 written by info.odysseyx@gmail.com August 22, 2024 0 comment 23 views 23 When you delete a job, all jobs and all job statistics belonging to that job are also deleted. It also ignores the retention period of job data. That is, if a job still contains jobs that are retained on compute nodes, the batch service deletes the job’s job directory and all its contents. When a request to delete a job is received, the batch service sets the job to the deleted state. Any update operations on a job in the deleted state fail with status code 409 (Conflict) and additional information indicating that the job is being deleted. The PowerShell command below allows you to delete a single task using its task ID. Remove-AzBatchJob -Id "Job-000001" -BatchContext $Context However, if you have a large number of tasks and want to delete them all at once, refer to the PowerShell command below. # Replace with your Azure Batch account name, resource group, and subscription ID $accountName = "yourBatchAccountName" $resourceGroupName = "yourResourceGroupName" # Authenticate to Azure Connect-AzAccount # Get the Batch account context $batchContext = Get-AzBatchAccount -Name $accountName -ResourceGroupName $resourceGroupName # Get all batch jobs with creation time before May 2024 # Replace the creation time date accordingly $jobsForDelete = Get-AzBatchJob -BatchContext $batchContext | Where-Object {$_.CreationTime -lt "2024-05-01"} # List the jobs Write-Host "Jobs to be deleted:" foreach ($job in $jobsForDelete) { Write-Host $job.Id # Write-Host "Deleting jobs..." Remove-AzBatchJob -Id $job.Id -BatchContext $batchContext -Force } The above script will delete all jobs created before the creation date. You can modify the parameters as per your needs. Source link Share 0 FacebookTwitterPinterestEmail info.odysseyx@gmail.com previous post Just a moment… next post Just a moment… You may also like AMD at Computex 2025: Creating the case for an AI Power House May 29, 2025 Dexcare AI Platform Access to Healthcare, Tackling Spend Crisis May 29, 2025 Cell Phone Satisfaction The Latest ACSI survey of ACSI falls below 10 years May 21, 2025 Democratic AI Revolution: Power and Code of People to People May 19, 2025 Apple adds a computer protocol from the brain to its accessibility Reptowar May 14, 2025 AI Brand Management Rules Writing again May 13, 2025 Leave a Comment Cancel Reply Save my name, email, and website in this browser for the next time I comment.