How it works...

After you have uploaded your function to AWS, click on the View menu in Visual Studio and select the AWS Explorer. Expanding the AWS Lambda node will show us the function we previously uploaded. If you see an error when expanding the node, you might need to give your user the ListFunctions permission. Expanding the AWS Identity and Access Management node will also show you the users, groups and roles you have configured. You can easily test your AWS Lambda function from within Visual Studio here by selecting one of the Example Requests and clicking on the Invoke button.

What we want to do, however, is hook up our S3 that stores files to send events to our function. Click on the Event Sources tab and click the Add button. Select Amazon S3 as the Source Type and select the familyvaultdocs bucket we created in the previous recipe. When you are done, click on the OK button.

Running the console application in the previous recipe to upload a new file to our S3 bucket will trigger our Lambda function. We can confirm this by looking at the Logs section in our function view.

You can also upload files from the AWS Explorer. Expand the Amazon S3 node and click on the Upload File button to the bucket.

Your file is uploaded and the progress is shown in the status window at the bottom.

While this example is not too complicated (with the exception of the permission settings perhaps), it does illustrate the concept of AWS Lambda functions. We can use the function to do a host of actions when triggered from something as simple as an event in an S3 bucket. Start to combine functionality and you can create a very powerful, serverless module to support and enhance your applications. 

It does not matter if you are using AWS, Azure or something such as DocRaptor (or any of the other 3rd party services available). Serverless computing is here to stay and C# Lambda functions will change the face of development in a big way.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.137.164.24