# need to try this: # https://learn.microsoft.com/en-us/azure/batch/quick-run-python # connect to Azure account: Connect-AzAccount # view resource groups Get-AzResourceGroup |Format-Table # list batch accounts Get-AzBatchAccount # view batch account info, first create $context parameter: # https://learn.microsoft.com/en-us/azure/batch/batch-powershell-cmdlets-get-started $context = Get-AzBatchAccountKeys -AccountName osbatchaccount # now run this command: Get-AzBatchPool -Id "osbatchpool" -BatchContext $context # delete batch account: Remove-AzBatchAccount -AccountName <account_name> # view batch node information # https://learn.microsoft.com/en-us/powershell/module/az.batch/?view=azps-11.0.0 Get-AzBatchComputeNode -PoolId "osbatchpool" -Id "nodeid" -BatchContext $context # view files and URL on a node in batch pool Get-AzBatchComputeNode "osbatchpool" -Id "nodeid" -BatchContext $context | Get-AzBatchNodeFile -BatchContext $context #-------------------------------------------------------------------------------- # check if python is installed using powershell: if ($pythonPath) { # Python is installed, get the version $pythonVersion = & $pythonPath --version 2>&1 Write-Output "Python is installed. Version: $pythonVersion" } else { Write-Output "Python is not installed on this node." } #-------------------------------------------------------------------------------- # commant to execute PS script powershell.exe -ExecutionPolicy Unrestricted -File CheckPython.ps1 # display all system variables unsing Powershell: dir env: # remove a single task in azure batch job Remove-AzBatchTask -JobId "myjob" -Id "mytask10" -BatchContext $context #-------------------------------------------------------------------------------- # remove all tsks in a batch job: # Get all tasks in the specified job $jobId = "adfv2-osbatchpool" $tasks = Get-AzBatchTask -JobId $jobId -BatchContext $context # Remove each task in the job foreach ($task in $tasks) { Remove-AzBatchTask -JobId $jobId -Id $task.Id -BatchContext $context } Write-Host "All tasks in the job have been removed."
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter