0

我一直在 .Net 核心项目中使用 GCP SecretManager,在访问放置在 GCP 中的秘密之一时,它会引发错误


Grpc.Core.RpcException: 'Status(StatusCode="Unavailable", Detail="未能连接到所有地址", DebugException="Grpc.Core.Internal.CoreErrorDetailException: {"created":"@1621849302.013000000","description" :"未能选择子频道","file":"......\src\core\ext\filters\client_channel\client_channel.cc","file_line":5397,"referenced_errors":[{"created" :"@1621849296.458000000","description":"连接所有地址失败","file":"......\src\core\ext\filters\client_channel\lb_policy\pick_first\pick_first.cc", "file_line":398,"grpc_status":14}]}")'


 public String AccessSecretVersion(string projectId = "strategic-ivy-310114", string secretId = "connectionString", string secretVersionId = "1")
    {
        var credential = GoogleCredential.FromFile(@"C:\Learning\SampleApps\CosmosWithSecret\CosmosDBApp\CosmosDb_Demo_Crud\strategic-ivy-615459-a0f786577j32.json");
        // Create the client.
        SecretManagerServiceClient client = SecretManagerServiceClient.Create();

        // Build the resource name.
        SecretVersionName secretVersionName = new SecretVersionName(projectId, secretId, secretVersionId);

        // Call the API.
        AccessSecretVersionResponse result = client.AccessSecretVersion(secretVersionName);

        // Convert the payload to a string. Payloads are bytes by default.
        String payload = result.Payload.Data.ToStringUtf8();
        return payload;
    }
4

0 回答 0