Amazon Systems Manager 和 Blazor Web Assembly

问题描述

我正在尝试构建 Blazor wasm 应用程序,并想从 Amazon Systems Manager 参数存储中检索我的敏感应用程序设置。我目前正在为 .Net core web api 后端使用相同的参数存储,但是当我尝试将它添加到我的 Blazor 应用程序时,我在网页开发人员控制台中收到以下异常...

Amazon.Runtime.AmazonServiceException: Unable to get IAM security credentials from EC2 Instance Metadata Service.
    at Amazon.Runtime.DefaultInstanceProfileAWSCredentials.FetchCredentials()
    at Amazon.Runtime.DefaultInstanceProfileAWSCredentials.GetCredentials()
    at Amazon.Runtime.DefaultInstanceProfileAWSCredentials.GetCredentialsAsync()
    at Amazon.Runtime.Internal.CredentialsRetriever.<InvokeAsync>2blazor.webassembly.js:1
    at Amazon.Runtime.Internal.RetryHandler.<InvokeAsync>d__10`1[[Amazon.SimpleSystemsManagement.Model.GetParametersByPathResponse,AWSSDK.SimpleSystemsManagement,Version=3.3.0.0,Culture=neutral,PublicKeyToken=removed]].MoveNext()
    at Amazon.Runtime.Internal.CallbackHandler.<InvokeAsync>d__9`1[[Amazon.SimpleSystemsManagement.Model.GetParametersByPathResponse,at Amazon.Runtime.Internal.ErrorCallbackHandler.<InvokeAsync>d__5`1[[Amazon.SimpleSystemsManagement.Model.GetParametersByPathResponse,PublicKeyToken=removed]].MoveNext()
    at Amazon.Runtime.Internal.MetricsHandler.<InvokeAsync>d__1`1[[Amazon.SimpleSystemsManagement.Model.GetParametersByPathResponse,PublicKeyToken=removed]].MoveNext()
    at Amazon.Extensions.Configuration.SystemsManager.Internal.SystemsManagerProcessor.GetParametersByPathAsync()
    at Amazon.Extensions.Configuration.SystemsManager.Internal.SystemsManagerProcessor.GetDataAsync()
    at Amazon.Extensions.Configuration.SystemsManager.SystemsManagerConfigurationProvider.LoadAsync(Boolean reload)
    at Amazon.Extensions.Configuration.SystemsManager.SystemsManagerConfigurationProvider.Load()
    at Microsoft.AspNetCore.Components.WebAssembly.Hosting.WebAssemblyHostConfiguration.Add(IConfigurationSource source)
    at Microsoft.Extensions.Configuration.SystemsManagerExtensions.AddSystemsManager(IConfigurationBuilder builder,Action`1 configureSource)
    at Microsoft.Extensions.Configuration.SystemsManagerExtensions.AddSystemsManager(IConfigurationBuilder builder,String path)
    at GoDay.Web.Program.Main(String[] args) in C:\Users\Joe\Development\goday\goday-web\GoDay.Web\Program.cs:line 27
    at Microsoft.AspNetCore.Components.WebAssembly.Hosting.EntrypointInvoker.InvokeEntrypoint(String assemblyName,String[] args)

我在 Program.cs 中使用的代码如下:

var builder = WebAssemblyHostBuilder.CreateDefault(args);
            builder.RootComponents.Add<App>("#app");

builder.Configuration.AddSystemsManager($"/my_app/{builder.HostEnvironment.Environment}/");

我还应该提到,我已经安装了 AWS CLI 并使用我的开发人员凭证进行了配置,并且我还安装了适用于 Visual Studio 2019 的 AWS 工具包。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)