AWS Steps to setup Serverless & Lambda

by Admin 11. February 2017 08:04

AWS Command Line Interface

AWS Toolkit for Visual Studio

Install NodeJS & Git Bash

install node js tools for visual studio

Install serverless globally

The commands are here

npm install serverless -g

Create an AWS Lambda function 

In Node.js

serverless create --template aws-nodejs

 In C#

 serverless create --template aws-csharp -p serverless-Sample1 -n LambdaService

Now open the project in Visual Studio

Add yaml Syntax Highlighting Pack nuget package


Modfiy the serverless.yml file to use the respective access credentails as below


  name: aws

  runtime: dotnetcore1.0

  stage: dev

  region: ${self:custom.configuration.providerRegion}


accessKeyId: ${self:custom.configuration.accessKeyId}

secretAccessKey: ${self:custom.configuration.secretAccessKey}


In the above I have referred the credentials and the region from an external config.yml file.

Here are the steps to do add the external file

Create a new config.yml file

Paste the below config stuff


 #AWS config

providerRegion: eu-west-2 (you need to set yours here)




Going back to servreless.yml file

You add / modify default settings

eg: I have added to exclude teh git stuff as part of the deployment package

# you can add packaging information here


  artifact: bin/release/netcoreapp1.0/publish/


  - .git/**

Now right click build.ps1 file and open with powershell

Now run this command 


Now the buid will be completed an places a folder in the below location and created a file to deploy


serverless-Sample1 is my application name

Now go to the gitbash "C:\VENKAT\Learning\AWS\Dev\Serverless-Sample1>" location

Now deploy the code on the serve rusing the following command

sls deploy

The above deploy happends from the default location as below


The code is successfully deployed on the server now.

Now go to the AWS Lamda

Search for Lamda

You should be able to view the lambda function we created

You can test by clicking the Test button.


Now its time to deploy the Lambda function on to the API Gateway

Go to the API gateway location by searching


Here you should be able to view the function which needs to be deployed on to API gateway

Now configure Method Execution  /users/create - GET - Method Request

You can add the 3 query params key1, key2 & key3

Now add a method HTTP Status: 200

Set the Use Lambda Proxy integration to False (UnCheck)


Now deploy the site from the Actions dropdown.

Test the function here 



Make sure you deploy


Deploy to live AWS account

serverless deploy

UFunction deployed!


Janisha-GBRL01483M17.pdf (566.60 kb)

Vijay-GBRL01481M17.pdf (564.19 kb)


AWS stuff

by Admin 10. February 2017 08:06

VPC - Virtual Private Cloud

State Machine is (also knows as work flow) or a group of states

Each state could be Task, Wait, Pass, Succeed, Fail, Choice, Parallel


Work Flow execution is an instance of the process or the work flow


Serverless N-Tier Architecture on AWS


Opsworks to build layers for presentation, integration and DB

Cloud formation to automate environment creation and update process


Dynamo DB ()  or RDS (Relational Database System)


Lambda functions represens the Dal

DAO Data access Object function


AWS API Gateway

Passthrough request


S3 Bucket


Runtime : Use nodeJs


S3 is an object storage service on Amazon cloud

IAM policies


2nd Type


Create Lambda functions using Cloud Formation

IAM rule

AWS Identity and Access Management (IAM) is a web service that helps 

you securely control access to AWS resources for your users. 

You use IAM to control who can use your AWS resources (authentication) 

and what resources they can use and in what ways (authorization).


State Machine

Step functions

AWS officially launced in 2006

Re-Invent Conference

Cloud Watch 

EC2 Elastic Compute Cloud 


 QR Code

 JSon is mostly Key Value pairs




 Accesskey id and secret key id is used only to use programatically interactiing with AWS

 username and password are only used when logging into the AWS console



 Simple Storage Service

 S3 is used to place to store the files in the cloud

 S3 is Object based storage (like videos/ images or any files etc to store the files)

 S3 is not Block based.

 files can me from 0bytes to 5TB

 Bucket is a folder

 files are stored in buckets

 Bucket names are unique globally

 when you upload a file in to S3 it returns a 200 status code



Common REST API Error Codes

by Admin 3. January 2017 01:03

The error codes listed in the following table may be returned by an operation on any of the storage services.

Error code

HTTP status code

User message


Not Modified (304)

The condition specified in the conditional header(s) was not met for a read operation.


Bad Request (400)

A required HTTP header was not specified.


Bad Request (400)

A required XML node was not specified in the request body.


Bad Request (400)

One of the HTTP headers specified in the request is not supported.


Bad Request (400)

One of the XML nodes specified in the request body is not supported.


Bad Request (400)

The value provided for one of the HTTP headers was not in the correct format.


Bad Request (400)

The value provided for one of the XML nodes in the request body was not in the correct format.


Bad Request (400)

A required query parameter was not specified for this request.


Bad Request (400)

One of the query parameters specified in the request URI is not supported.


Bad Request (400)

An invalid value was specified for one of the query parameters in the request URI.


Bad Request (400)

A query parameter specified in the request URI is outside the permissible range.


Bad Request (400)

The url in the request could not be parsed.


Bad Request (400)

The requested URI does not represent any resource on the server.


Bad Request (400)

The HTTP verb specified was not recognized by the server.


Bad Request (400)

The key for one of the metadata key-value pairs is empty.


Bad Request (400)

The specified XML is not syntactically valid.


Bad Request (400)

The MD5 value specified in the request did not match the MD5 value calculated by the server.


Bad Request (400)

The MD5 value specified in the request is invalid. The MD5 value must be 128 bits and Base64-encoded.


Bad Request (400)

One of the request inputs is out of range.


Bad Request (400)

The authentication information was not provided in the correct format. Verify the value of Authorization header.


Bad Request (400)

One of the request inputs is not valid.


Bad Request (400)

The specified metadata is invalid. It includes characters that are not permitted.


Bad Request (400)

The specifed resource name contains invalid characters.


Bad Request (400)

The size of the specified metadata exceeds the maximum size permitted.


BadRequest (400)

Condition headers are not supported.


Bad Request (400)

Multiple condition headers are not supported.


Forbidden (403)

Server failed to authenticate the request. Make sure the value of the Authorization header is formed correctly including the signature.


Forbidden (403)

Read operations are currently disabled.


Forbidden (403)

Write operations are not allowed.


Not Found (404)

The specified resource does not exist.


Forbidden (403)

The specified account is disabled.


Forbidden (403)

The account being accessed does not have sufficient permissions to execute this operation.


Method Not Allowed (405)

The resource doesn't support the specified HTTP verb.


Conflict (409)

The specified account already exists.


Conflict (409)

The specified account is in the process of being created.


Conflict (409)

The specified resource already exists.


Conflict (409)

The specified resource type does not match the type of the existing resource.


Length Required (411)

The Content-Length header was not specified.


Precondition Failed (412)

The condition specified in the conditional header(s) was not met for a write operation.


Request Entity Too Large (413)

The size of the request body exceeds the maximum size permitted.


Requested Range Not Satisfiable (416)

The range specified is invalid for the current size of the resource.


Internal Server Error (500)

The server encountered an internal error. Please retry the request.


Internal Server Error (500)

The operation could not be completed within the permitted time.


Service Unavailable (503)

The server is currently unable to receive requests. Please retry your request.











































































































Angular CLI shortcuts

by Admin 16. September 2016 03:06


Angular CLI shortcuts
To install Angular CLI, run: $ npm install -g angular-cli

Generate a my-sample application: $ ng new my-sample

# Generate a new component
$ ng generate component my-new-component

# Generate a new directive
$ ng generate directive my-new-directive

# Generate a new pipe
$ ng generate pipe my-new-pipe

# Generate a new service
$ ng generate service my-new-service

# Generate a new class
$ ng generate class my-new-class

# Generate a new interface
$ ng generate interface my-new-interface

# Generate a new enum
$ ng generate enum my-new-enum


Angular2 stuff

by Admin 6. September 2016 07:23


The * before the ngFor denotes the fact that *ngFor is what is called a structural directive, a directive that is going to affect the DOM in some way adding or removing elements to it.


Backtick (`) are used to define the new ES6 template strings. They are a new great feature of ES6 that let’s you write multiline strings natively and insert any expression directly within a string with a very straightforward syntax.


Why don’t we use the Injectable decorator in components? 

Well that’s because the Component decorator enables dependency injection directly.


Angular 2 has support for these data-bindings:

1. Interpolation: One-way data binding from the component to the template. Let’s you display information from the component into the template. Example: {{}}.

2. Property bindings: One-way data binding from the component to the template. Let’s you bind data from the component into the template. Example: [src]="user.imageUrl".

3. Event bindings: One-way data binding from the template to the component. Let’s you bind template events to the component. Example [click)="selectuser(user)".

4. [(ngModel)]: Two-way data binding from the component to the template and vice versa. Example [(ngModel)]="".


VS 2015 Error Install-Package : Unable to load the service index for source

by Admin 8. May 2016 07:56

Visual Studio 2015 Error Install-Package : Unable to load the service index for source

Fix : 

1. Close your Visual Studio 2015

2. Navigate to %AppData%\NuGet\ folder 

3. Delete the NuGet.config file

4. Now open Visual Studio. You can notice that a new NuGet.Config file is generated

This fixes the issue


RenderPartialViewToString / Return multiple partial views in JSON - MVC6

by Admin 5. May 2016 00:00

I got a situation where we need to dynamically render multiple partial views and bid on the view in MVC6

So Here is the solution.

This is the common method for rendering the partial views as strings

protected string RenderPartialViewToString(string viewName, object model)


            if (string.IsNullOrEmpty(viewName))

                viewName = ActionContext.ActionDescriptor.Name;


            ViewData.Model = model;


            using (var sw = new StringWriter())


                var engine = Resolver.GetService(typeof(ICompositeViewEngine))

                    as ICompositeViewEngine;

                var viewResult = engine.FindPartialView(ActionContext, viewName);


                var viewContext = new ViewContext(






                    new HtmlHelperOptions()


                //Everything is async now!

                var t = viewResult.View.RenderAsync(viewContext);


                return sw.GetStringBuilder().ToString();




Here is the method for the view which returns multiple partial view results as JSON

public async Task<ActionResult> GetMultiplePartialsAsync(Your input parameters go here)


            var viewModel = await _myService.FetchDatasAsync(Your input parameters go here);

   //For brevity I am assigning the same view model to all the partial views.

   //You can have sub models in the view model too

                var json = Json(new


                    FilterPartialViewHtml = RenderPartialViewToString("PagedResults", viewModel),

                    CountriesPartialViewHtml = RenderPartialViewToString("Countries", viewModel),

                    NamesPartialViewHtml = RenderPartialViewToString("Names", viewModel)


                return json;




Here is my View which load all the 3 partial views on load & on click of a checkbox

Note that the paritals are loaded on load as well as gets reladed on all onchange events of the checkbox for countries & Names

@model ResultViewModel


    Layout = "~/Views/Shared/_DemoLayout.cshtml";


<div id="wrapper">

    <main id="content" role="main">


            <div class="filtering">

                <div class="filter-form">

                    <div class="inner-block">

                        <form method="get" action="Filter">

                            <div class="filter text-filter">

                                <label class="legend" for="finder-keyword-search">Search</label>

                                <input value="" type="text" name="Keywords" id="Keywords" aria-controls="js-search-results-info" class="text">


                            <div id="divCenturies">


                            <div id="divLastNames">





                <div class="js-live-search-results-block">

                    <div class="filtered-results">

                            <div id="searchResults">









    var url = '@Url.Action("GetMultiplePartialsAsync", "Search")';


    $(window).load(function () {





    $(document).ready(function () {




        $(document).on("change", "input[type=checkbox]", function () {




        $("#Keywords").change(function () {



        $("#Keywords").keypress(function (e) {

            if ((e.keyCode || e.which) == 13) {







    function SearchData() {

        $.get(url, { Your input parameters here },

                function (data) {












.NET core features

by Admin 7. April 2016 02:26


.NET core

DNX – Dot Net Execution Environment

Native process for hosting the CLR (dnx.exe)

Includes compiler and xpat tools for building .NET apps

Xpat/ OSS friendly project system (project.json)

Package based (install, restore, pack)

Side by side versioning (Manage DNX’s with the .Net Version Manager (DNVM)

Rosyln compiler  


Angular2 Stuff

by Admin 1. April 2016 02:13

Angular2 Style guide

IDE to use

Visual studio code

Other Nice Editors 

1. Atom: (Free editor, created by the Github guys. Allows you to add plugins and change appearance with third-party packages)

2. Sublime: (very modular. Allows you to add plugins and change appearance with third-party packages.)


TypeScript is the language of choice for Angular 2 development. It’s a superset to JavaScript which gets compiled into plain JavaScript. The main feature it

adds are the Types, which make development easier (autocompletion etc.) and less error-prone (compiler errors).

Visual studio code nice intro videos which has got Typescript debugging


Autofac Dependency Injection in ASP.NET 5

by Admin 21. March 2016 11:50

A. Add the following Autofac reference in the project.json file

                        "Autofac.Extensions.DependencyInjection": "4.0.0-rc1-177"

               Note: the version number might change based on the new releases

B. Introduce the following changes in the Startup.CS file

1. Change the method return type from Void to IServiceProvider like this

                         public IServiceProvider ConfigureServices(IServiceCollection services)

2. Add the following line items after  // Add application services.

            //Autofac DI 

            var builder = new ContainerBuilder();


            builder.RegisterType<TestService>().As<ITestService>().InstancePerDependency();   // This is a test class and interface I have added on to the              project.


            var container = builder.Build();

            return container.Resolve<IServiceProvider>();

3. Usage is quite straight forward as in previous versions

   I have tried implementing in the HomeController.

private readonly ITestService _testService;

        public HomeController(ITestService testService)


            _testService = testService;


        public IActionResult Index()


            ViewData["temp"] = _testService.GetTestString();

            return View();


Thats it!         





Tag cloud