[英]AWS Lambda - Could not determine an appropriate location for storing user secrets
We published our Net6 web API to an AWS Lambda but when we make a request it fails.我们将 Net6 web API 发布到 AWS Lambda,但是当我们发出请求时它失败了。
Status: 502 Bad Gateway状态:502 错误网关
{
"message": "Internal server error"
}
We get this on CloudWatch:我们在 CloudWatch 上得到这个:
2022-09-01T10:42:07.359-03:00 Unhandled exception. System.InvalidOperationException: Could not determine an appropriate location for storing user secrets. Set the DOTNET_USER_SECRETS_FALLBACK_DIR environment variable to a folder where user secrets should be stored.
2022-09-01T10:42:07.359-03:00 at Program.<Main>$(String[] args) in C:\repository\codetria\palier\backend\backend-palier\Src\Presentation\Palier.API\Program.cs:line 12
Program.cs - line 12: Program.cs - 第 12 行:
var builder = WebApplication.CreateBuilder(args);
It's not the first time that we published an API in this way and we've never had to set this environment variable.这不是我们第一次以这种方式发布 API,而且我们从来没有设置过这个环境变量。
This's the command we use to publish the API这是我们用来发布 API 的命令
dotnet lambda deploy-function lambda-name `
--region us-east-2 `
--project-location $API_LOCATION `
--profile profile `
--function-runtime dotnet6
Any thoughts?有什么想法吗?
I just a similar error trying to deploy to AWS, for me it turned out to be that I a UserSecretsId
in my csproj by mistake.我只是在尝试部署到 AWS 时遇到类似的错误,对我来说,结果是我错误地在我的 csproj 中输入了
UserSecretsId
。 The error went away when I remove this value.当我删除此值时,错误消失了。 Here is a reference on how to use UserSecrets in deployed environments https://learn.microsoft.com/en-us/as.net/core/security/app-secrets?view=as.netcore-6.0&tabs=windows
这是有关如何在已部署环境中使用 UserSecrets 的参考https://learn.microsoft.com/en-us/as.net/core/security/app-secrets?view=as.netcore-6.0&tabs=windows
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.