如何删除databricks azure中的所有群集,而不是搜索和复制cluster_id?

时间:2020-01-14 16:10:20

标签: azure rest databricks azure-databricks

我想实用地删除一组群集。假设它们只是一些测试的目的之一,我想立即删除它们。

我认为,当我将所有群集分配给特定池时,也许是可行的,但是似乎池API不会返回有关分配给它的群集的信息。

还有其他想法吗?

thx

1 个答案:

答案 0 :(得分:1)

您可以使用此module在PowerShell中轻松完成此操作。我在下面测试了此脚本并像魅力

一样工作
$databricksBearerToken = "" # enter your manually generated token here 
$databricksRegion = "" # enter region for the workspace here 
$databricksWorkSpaceName = "" # enter the name of your databricks workspace

# Return a list of existing clusters
$myclusters = Get-DatabricksClusters -BearerToken $databricksBearerToken -Region $databricksRegion

# Iterate through these clusters and remove them one by one
Foreach($cluster in $myclusters)
{ 
  $clusterName = $cluster.cluster_name
  $clusterID = $cluster.cluster_id
  Write-Host $clusterName
  Remove-DatabricksCluster -BearerToken $databricksBearerToken -Region $databricksRegion -ClusterName $clusterName -ClusterId $clusterID
}