Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@IntegerMan
Created July 5, 2022 03:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IntegerMan/24103bc0ee748ef42f569e95459a525c to your computer and use it in GitHub Desktop.
Save IntegerMan/24103bc0ee748ef42f569e95459a525c to your computer and use it in GitHub Desktop.
from azureml.core import Workspace
from azureml.core.compute import ComputeTarget
from azureml.core.compute_target import ComputeTargetException
# Load the workspace from config.json
ws = Workspace.from_config()
# Now let's make sure we have a compute resource
instance_name = "My-Compute"
# Fetch or create the compute resource
try:
instance = ComputeTarget(workspace=ws, name=instance_name)
instance.delete()
instance.wait_for_completion(show_output=True)
print('Deleted compute resource')
except ComputeTargetException:
print('Already deleted!')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment