微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Amazon Systems Manager 和 Blazor Web Assembly

如何解决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 举报,一经查实,本站将立刻删除。