Share via

delete compute instance by python sdk

Trujillo Rodriguez Carlos Rene 1 Reputation point
2023-01-04T20:01:05.81+00:00

hello

I request your help to configure the deletion of the azure machine learning compute instance after the job is finished

Azure Container Instances
Azure Machine Learning
0 comments No comments

1 answer

Sort by: Most helpful
  1. Ramr-msft 17,836 Reputation points
    2023-01-17T11:53:28.6466667+00:00

    @Trujillo Rodriguez Carlos Rene Thanks for the question. To delete a compute instance using the Azure Machine Learning Python SDK, you can use the ComputeInstance.delete() method. This method is part of the azureml.core.compute.ComputeInstance class and is used to delete a compute instance.

    Here's an example of how you can delete a compute instance:

    from azureml.core import Workspace  
    from azureml.core.compute import ComputeInstance  
      
    # Load the workspace  
    ws = Workspace.from_config()  
      
    # Get the compute instance  
    compute_instance = ComputeInstance(ws, "my-compute-instance")  
      
    # Delete the compute instance  
    compute_instance.delete()  
    

    This example assumes that you have already authenticated with Azure and have a valid Workspace object, as well as the name of the compute instance you want to delete.

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.