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 4 views 4 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 Copilot for Microsoft Fabric – Starter Series Healthcare Focus September 12, 2024 More ways to sell through the marketplace with professional services September 11, 2024 Two upcoming Copilot and M365 for SMB Community offerings September 11, 2024 Copilot for Microsoft 365 Adoption Trainings September 11, 2024 Omdia’s perspective on Microsoft’s SSE solution September 11, 2024 Extend Viva Connections with pre-built 3rd party Adaptive cards September 11, 2024 Leave a Comment Cancel Reply Save my name, email, and website in this browser for the next time I comment.