使用 Powershell 执行 .Netcore Visual Studio AWS 工具包 'Publish to AWS Lambda...'
Using Powershell to perform the .Netcore Visual Studio AWS Toolkit 'Publish to AWS Lambda...'
我使用 Visual Studio 2017 和 AWS Toolkit 开发了一个 .Net Core lambda 函数。我在名为 serverless.template 的文件中有 Cloudformation 脚本,在名为 aws-lambda-tools-defaults.json 的文件中有部署配置。在开发项目时,我一直在使用解决方案资源管理器中的 'Publish to AWS Lambda...' 右键单击选项将其部署到 AWS 开发帐户。
我现在准备好将其部署到我们的暂存和生产 AWS 账户,并且需要使用 Cloudformation 执行 'Publish to AWS Lambda...' 部署步骤,我们希望创建 Cloudformation 变更集,以允许审查在部署之前。
我一直在努力弄清楚该怎么做,并尝试了 'aws cloudformation package' 和 'sam package' CLI 命令,但我似乎找不到前进的方向。
任何人都可以帮助我理解 'Publish to AWS Lambda...' 执行的步骤吗?我想在 Powershell 中重现这些步骤,因为这将为我提供继续前进所需的理解。
谢谢。
要从命令行部署,请对 Lambda 使用 dotnet CLI extension。当您从向导发布时,它与在 Visual Studio 内运行的代码相同,并且可以读取默认文件等,因此无论您是从 IDE 还是命令行部署,您都可以获得一致的部署体验。
您提到您想了解幕后发生的事情 - 这些工具是开源的,因此您可以在 GitHub repository 中查看它为您所做的所有工作。部署无服务器应用程序时,会自动使用 CloudFormation 更改集,您无需自己处理。
该工具是您首先从命令行安装的 .NET Core 全局工具:
dotnet tool install -g Amazon.Lambda.Tools
安装后,您可以获得帮助等:
PS C:\> dotnet lambda help
Amazon Lambda Tools for .NET Core applications (3.2.0)
Project Home: https://github.com/aws/aws-extensions-for-dotnet-cli, https://github.com/aws/aws-lambda-dotnet
Commands to deploy and manage AWS Lambda functions:
deploy-function Command to deploy the project to AWS Lambda
invoke-function Command to invoke a function in Lambda with an optional input
list-functions Command to list all your Lambda functions
delete-function Command to delete a Lambda function
get-function-config Command to get the current runtime configuration for a Lambda function
update-function-config Command to update the runtime configuration for a Lambda function
Commands to deploy and manage AWS Serverless applications using AWS CloudFormation:
deploy-serverless Command to deploy an AWS Serverless application
list-serverless Command to list all your AWS Serverless applications
delete-serverless Command to delete an AWS Serverless application
Commands to publish and manage AWS Lambda Layers:
publish-layer Command to publish a Layer that can be associated with a Lambda function
list-layers Command to list Layers
list-layer-versions Command to list versions for a Layer
get-layer-version Command to get the details of a Layer version
delete-layer-version Command to delete a version of a Layer
Other Commands:
package Command to package a Lambda project into a zip file ready for deployment
package-ci Command to use as part of a continuous integration system.
To get help on individual commands execute:
dotnet lambda help <command>
要从命令行部署项目,首先 cd 进入项目文件夹然后执行命令
dotnet lambda deploy-serverless
这将读取默认文件中的设置并为您执行部署,就像您使用 IDE 向导一样。
希望这与开源存储库一起帮助您深入了解所涉及的步骤。
我使用 Visual Studio 2017 和 AWS Toolkit 开发了一个 .Net Core lambda 函数。我在名为 serverless.template 的文件中有 Cloudformation 脚本,在名为 aws-lambda-tools-defaults.json 的文件中有部署配置。在开发项目时,我一直在使用解决方案资源管理器中的 'Publish to AWS Lambda...' 右键单击选项将其部署到 AWS 开发帐户。
我现在准备好将其部署到我们的暂存和生产 AWS 账户,并且需要使用 Cloudformation 执行 'Publish to AWS Lambda...' 部署步骤,我们希望创建 Cloudformation 变更集,以允许审查在部署之前。
我一直在努力弄清楚该怎么做,并尝试了 'aws cloudformation package' 和 'sam package' CLI 命令,但我似乎找不到前进的方向。
任何人都可以帮助我理解 'Publish to AWS Lambda...' 执行的步骤吗?我想在 Powershell 中重现这些步骤,因为这将为我提供继续前进所需的理解。
谢谢。
要从命令行部署,请对 Lambda 使用 dotnet CLI extension。当您从向导发布时,它与在 Visual Studio 内运行的代码相同,并且可以读取默认文件等,因此无论您是从 IDE 还是命令行部署,您都可以获得一致的部署体验。
您提到您想了解幕后发生的事情 - 这些工具是开源的,因此您可以在 GitHub repository 中查看它为您所做的所有工作。部署无服务器应用程序时,会自动使用 CloudFormation 更改集,您无需自己处理。
该工具是您首先从命令行安装的 .NET Core 全局工具:
dotnet tool install -g Amazon.Lambda.Tools
安装后,您可以获得帮助等:
PS C:\> dotnet lambda help
Amazon Lambda Tools for .NET Core applications (3.2.0)
Project Home: https://github.com/aws/aws-extensions-for-dotnet-cli, https://github.com/aws/aws-lambda-dotnet
Commands to deploy and manage AWS Lambda functions:
deploy-function Command to deploy the project to AWS Lambda
invoke-function Command to invoke a function in Lambda with an optional input
list-functions Command to list all your Lambda functions
delete-function Command to delete a Lambda function
get-function-config Command to get the current runtime configuration for a Lambda function
update-function-config Command to update the runtime configuration for a Lambda function
Commands to deploy and manage AWS Serverless applications using AWS CloudFormation:
deploy-serverless Command to deploy an AWS Serverless application
list-serverless Command to list all your AWS Serverless applications
delete-serverless Command to delete an AWS Serverless application
Commands to publish and manage AWS Lambda Layers:
publish-layer Command to publish a Layer that can be associated with a Lambda function
list-layers Command to list Layers
list-layer-versions Command to list versions for a Layer
get-layer-version Command to get the details of a Layer version
delete-layer-version Command to delete a version of a Layer
Other Commands:
package Command to package a Lambda project into a zip file ready for deployment
package-ci Command to use as part of a continuous integration system.
To get help on individual commands execute:
dotnet lambda help <command>
要从命令行部署项目,首先 cd 进入项目文件夹然后执行命令
dotnet lambda deploy-serverless
这将读取默认文件中的设置并为您执行部署,就像您使用 IDE 向导一样。
希望这与开源存储库一起帮助您深入了解所涉及的步骤。