简体   繁体   中英

Bulk AWS Lambda Upload from Visual Studio

Using the AWS tool plugin for Visual Studio, how do you do a bulk upload of Lambda functions to AWS?

I have a project that contains two functions that define separate lambda functions. The context menu for AWS Lambda seems to only allow for publishing one function at a time. As you can imagine, that is a bit of a maintainability nightmare.

The json config file that it generates does not have any answers either as it seems to be pretty flat and only allows a single function at a time:

"region"      : "us-west-2",
"configuration" : "Release",
"framework"     : "netcoreapp1.0",
"function-runtime" : "dotnetcore1.0",
"function-memory-size" : 256,
"function-timeout"     : 5,
"function-handler"     : "LambdaSamples::LambdaSamples.SampleFunction::HelloWorld",
"function-name"        : "HelloWorld",
"function-role"        : "lambda_basic_execution",
"environment-variables" : ""

The Visual Studio project called "AWS Lambda Project" is designed for single Lambda functions.

So if your solution has multiple projects, and you want to deploy them all at once, you're best off doing it by script/command line.

The Readme.md file generated by the new project wizard has instructions on deploying by command line using dotnet lambda deploy-function .

I generally create an options file for each type of release that I want, like this (the new file is aws-options-live.json and has a specific name / env variables pertaining to my live environment):

aws 选项

And then use the following in a batch file in a Deploy folder off of the main solution folder:

echo off
cd ..\ApiGatewayLambda
dotnet lambda deploy-function -cfg aws-options-live.json
set /p asd="Hit enter to continue"

You can then get as clever as you want to with linking multiple uploads together / error checking etc.

You can still right click on the project and choose Public to AWS Lambda - it will use the aws-lambda-tools-defaults.json file to publish the function.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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