billmanH
billmanH

Reputation: 1426

Possibility to create and delete databricks resources via Azure CLI deployments

Normally when you create resources using ARM templates and the azure CLI you can create using:

az deployment group create --resource-group $resourceGroupName --template-file "infra/template.json" --parameters "infra/parameters.json"

Then when I want to delete the resources I can:

az group delete --name $resourceGroupName

However, with Databricks this will create other resource groups as well. Even if you delete the DB resource group, you've still got these other lingering resource groups. I'd like to be able to delete the databricks AND all of the other resources that were created, without having to do extra manual steps.

Any idea of a clean way to do this?

Upvotes: 0

Views: 374

Answers (1)

tanikellav
tanikellav

Reputation: 124

The managed resource group created by Databricks cannot be deleted manually since it was created by the Databricks resource itself. The deny assignment prevents deletion of the managed resource group.

One way to remove resource is to delete the existing workspace following is the example using azure cli

Through AZURE CLI

I have created resource group tvs and databricks tvs for the demo purpose

Delete resource

Use following command in AzureCLI to delete a resource.

Azure CLICopy

az resource delete \
--resource-group tvs\
--name  tvs\
--ids  *****\

(NOTE : ids is the id of the resource that can be picked from JSON view)

Before deletion

enter image description here

enter image description here

After deletion

enter image description here

Delete resource group

Use following command in AzureCLI to delete the resource group.

Azure CLICopy

az group delete --name tvs

enter image description here

Azure doesn’t currently provide a way to delete multiple resource groups at the same time.

Here’s a method that works for me.

  1. Open Azure Portal
  2. Click on Resource Groups
  3. Select the Resource Groups that you want to delete
  4. Click “Assign tags”

enter image description here

  1. Assign a new tag called “disposable-service”(can be named anything) and tag value to be true

enter image description here

  1. Open Azure Cloud Shell https://shell.azure.com or click on the Azure Shell icon in the Azure Portal toolbar.

  2. the following script into Cloud Shell and hit enter.

az group list --tag disposable-service=true --query "[].[id]" --output tsv

enter image description here

Upvotes: 1

Related Questions