Reputation: 2835
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
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