简体   繁体   English

使用 dotnet 5 访问 GCP 机密管理器时出现问题

[英]Issue accessing GCP secrets manager using dotnet 5

I am using Google.Cloud.SecretManager.V1 in my .NET 5 aspnet core application.我在我的 .NET 5 aspnet 核心应用程序中使用 Google.Cloud.SecretManager.V1。 I am containerizing application to run as linux container on GCP Cloud run.我正在容器化应用程序以在 GCP Cloud 运行中作为 linux 容器运行。 I get following exception while creating SecretManagerServiceClient创建 SecretManagerServiceClient 时出现以下异常

//call SDK
SecretManagerServiceClient client = SecretManagerServiceClient.Create();


System.DllNotFoundException: Unable to load shared library 'libdl.so' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: liblibdl.so: cannot open shared object file: No such file or directory
   at Grpc.Core.Internal.UnmanagedLibrary.Linux.dlopen(String filename, Int32 flags)
   at Grpc.Core.Internal.UnmanagedLibrary.LoadLibraryPosix(Func`3 dlopenFunc, Func`1 dlerrorFunc, String libraryPath, String& errorMsg)
   at Grpc.Core.Internal.UnmanagedLibrary.PlatformSpecificLoadLibrary(String libraryPath, String& errorMsg)
   at Grpc.Core.Internal.UnmanagedLibrary..ctor(String[] libraryPathAlternatives)
   at Grpc.Core.Internal.NativeExtension.LoadUnmanagedLibrary()
   at Grpc.Core.Internal.NativeExtension.LoadNativeMethods()
   at Grpc.Core.Internal.NativeExtension..ctor()
   at Grpc.Core.Internal.NativeExtension.Get()
   at Grpc.Core.Internal.NativeMethods.Get()
   at Grpc.Core.GrpcEnvironment.GrpcNativeInit()
   at Grpc.Core.GrpcEnvironment..ctor()
   at Grpc.Core.GrpcEnvironment.AddRef()
   at Grpc.Core.Channel..ctor(String target, ChannelCredentials credentials, IEnumerable`1 options)
   at Google.Api.Gax.Grpc.GrpcCore.GrpcCoreAdapter.CreateChannelImpl(String endpoint, ChannelCredentials credentials, GrpcChannelOptions options)
   at Google.Api.Gax.Grpc.GrpcAdapter.CreateChannel(String endpoint, ChannelCredentials credentials, GrpcChannelOptions options)
   at Google.Api.Gax.Grpc.ChannelPool.GetChannel(GrpcAdapter grpcAdapter, String endpoint, GrpcChannelOptions channelOptions, ChannelCredentials credentials)
   at Google.Api.Gax.Grpc.ChannelPool.GetChannel(GrpcAdapter grpcAdapter, String endpoint, GrpcChannelOptions channelOptions)
   at Google.Api.Gax.Grpc.ClientBuilderBase`1.CreateCallInvoker()
   at Google.Cloud.SecretManager.V1.SecretManagerServiceClientBuilder.BuildImpl()
   at Google.Cloud.SecretManager.V1.SecretManagerServiceClientBuilder.Build()
   at Google.Cloud.SecretManager.V1.SecretManagerServiceClient.Create()

Same code works fine if I use aspnetcore 3.1 image.如果我使用 aspnetcore 3.1 图像,相同的代码可以正常工作。 NET 5 is supposed to be upgrade of .NET core 3.1 and backward compatible. NET 5 应该是 .NET 核心 3.1 的升级并向后兼容。 So, I am curious and what could be done to make this code work on .NET 5所以,我很好奇,可以做些什么来使这个代码在 .NET 5 上工作

I posted this answer to make a solution from the comment section more visible.我发布了这个答案,以使评论部分的解决方案更加明显。

As it was suggested by @John Hanley and confirmed by @SmartCoder this issue was solved by adding to the Docker file lines below:正如@John Hanley所建议并由@SmartCoder确认的那样,此问题已通过添加到下面的 Docker 文件行来解决:

RUN apt-get update -y 
RUN apt-get install -y libc6-dev 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM