Warrick FitzGerald
Warrick FitzGerald

Reputation: 2835

Delete GCP Spanner Instance using dotnet core \ c#

I'm trying to find an example of how to delete a GCP Spanner Instance using dotnet core \ C# library.

This provides an example of how to create an instance, but I can't seem to figure out how to delete an instance via code. https://cloud.google.com/spanner/docs/samples/spanner-create-instance

Upvotes: 0

Views: 63

Answers (1)

Lakshmi Pallikila
Lakshmi Pallikila

Reputation: 336

Based on the API documentation and guidelines, below code snippet should work.

public class DeleteInstanceSample
{
   public Instance DeleteInstance(string projectId, string instanceId)
   {
    // Create the InstanceAdminClient instance.
    InstanceAdminClient instanceAdminClient = InstanceAdminClient.Create();

    InstanceName instanceName = InstanceName.FromProjectInstance(projectId, instanceId);
    
    instanceAdminClient.DeleteInstance(instanceName);

    Console.WriteLine("Instance deleted successfully.");
  }
}

Upvotes: 3

Related Questions