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 Container Instances
An Azure service that provides customers with a serverless container experience.
757 questions
Azure Machine Learning
Azure Machine Learning
An Azure machine learning service for building and deploying models.
3,336 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Ramr-msft 17,826 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 Answers by the question author, which helps users to know the answer solved the author's problem.