【问题标题】:Delete GCP Spanner Instance using dotnet core \ c#使用 dotnet core \ c# 删除 GCP Spanner Instance
【发布时间】:2020-12-16 18:34:29
【问题描述】:

我正在尝试查找如何使用 dotnet core \ C# 库删除 GCP Spanner 实例的示例。

这提供了如何创建实例的示例,但我似乎无法弄清楚如何通过代码删除实例。 https://cloud.google.com/spanner/docs/samples/spanner-create-instance

【问题讨论】:

    标签: c# .net-core google-cloud-platform google-cloud-spanner


    【解决方案1】:

    根据 API 文档和指南,下面的代码 sn-p 应该可以工作。

    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.");
      }
    }
    

    【讨论】:

    猜你喜欢
    • 2023-03-22
    • 2023-02-18
    • 2021-12-27
    • 1970-01-01
    • 2019-06-16
    • 1970-01-01
    • 2017-07-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多