Amazon Stuff

by Admin 11. April 2017 06:56


Cloud Formation
Allows to create scripts to deploy infrastructure

The default scripting language for CloudFormation is JSON
Cloud Formation itself is free, however the resources it provisions will be charged at the usual rates.

What happens if Cloud Formation encounters an error by default?
It will terminate and rollback all resources created on failure.

You are creating a virtual data centre using cloud formation and you need to output the DNS name of your load balancer. What command would you use to achieve this?

What language are cloud formation templates written in?


SQS (Simple Queue Service)

Messages can be 256kb of data

Amazon SQS ensures delivery of each message at least once, and supports multiple readers and writers interacting with the same queue.

A single queue can be used simultaneously by many distributed application components, with no need for thoese components to coordinate with each other to share the queue.

SQS asynchronously pulls the task messages from the queue and cannot guarantee first in first out from the queue. If the system requires that the order be preserved, you can place sequencing information in each message, so that you can reorder the messages when the queue returns them.

image pooling and retrieve steps

Asynchronously pulls the task messages from the queue

Retrieves the named file

Processes the conversation

Writes the image back to Amazon S3

Writes a "Task Complete" message to another queue

 Deletes the original task message

Checks for more messages in the worker queue

SQS was the first service on the AWS platform
Does not offer FIFO
12 hrs visibility timeout
default visibility time out setting by default is 30 seconds.
Can extend / change by using the ChangeMessageVisibility action to specify a new timeout value
256kb  SQS message size now availble
Maximum Long Poll Time Out = 20 Seconds

Autoscalling application servers
SQS Messages can be delivered multiple times and in any order.

You are designing a new application which involves processing payments and delivering promotional emails to customers. You plan to use SQS to help facilitate this. You need to ensure that the payment process takes priority over the creation and delivery of emails. What is the best way to achieve this.

Use 2 SQS queues for the platform. Have the EC2 fleet poll the payment SQS queue first. If this queue is empty, then poll the promotional emails queue.

Your EC2 instances download jobs from the SQS queue, however they are taking too long to process them. What API call can you use to extend the length of time to process the jobs?

You have a fleet of EC2 instances that are constantly polling empty SQS queues which is burning CPU compute cycles and costing your company money. What should you do?
Enable SQS Long Polling

What amazon service can you use in conjunction with SQS to "fan out" SQS messages to multiple queues.


SNS (Simple Notification Service)
SNS is Push based notification service
> Topics
> Subscriptions

Messages can be customized for each protocol used in SNS

You have a list of subscribers email addresses that you need to push emails out to on a periodic basis. What do you subscribe them to?
Answer: Topic

You can use SNS in conjunction with SQS to fan a single message out to multiple SQS queues.




Formatting JSON output in CamelCase versus the default .NET's PascalCase

by Admin 24. February 2017 07:27

Add to your WebApiConfig.cs file (under App_Start folder at WebApi 2) the following two lines:

// Get the default json formatter
var jsonFormatter = config.Formatters.OfType<JsonMediaTypeFormatter>().First();

// Switch from PascalCase to CamelCase
jsonFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();


.NET Core

public void ConfigureServices(IServiceCollection services)



                    .AddJsonOptions(options =>


                        options.SerializerSettings.ContractResolver =

                            new CamelCasePropertyNamesContractResolver();




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


Remove all

C:\TFS\AWSPrj> .\scripts\RemoveAllServices <environmentName>



Update Node / Yarn to a specific version

by Admin 25. January 2017 02:24

Update Node to a specific version

npm install npm@5.6.0 -g

Update Yarn to a specific version

npm install yarn@1.3.2 -g


C# 6 & 7 features

by Admin 5. January 2017 09:39

C# 7.0 features

C# 6.0 features

Roslyn, a new compiler introduced in C# 6.0. 

8 useful features in C# 6.

1.Auto Property Initializers

2.using static

3.Null Conditional Operator

4. Exception Filters

5. await in Catch and Finally block

6. index initializers

7. Expression Bodied functions

8. String Interpolation


1. Auto Property Initializers

It allows you to set an initial value for auto initializer. In earlier C# version this feature was not available.

Below is the code snippet.

 public class Customer


        public Guid customerID { get; set; } = Guid.NewGuid();


2. using static

It allows you to import the static methods of a single class.

for eg -instead of writing using System;

We can now write.

using static System.Console;

using static System.Math

See below code snippet.

using static System.Console;

            //Before C# 6.0


            //After C# 6.0

            WriteLine("Welcome to C#"); 



3. Null-Conditional Operator

NULL Reference error always threatens to the developer. In C# 6.0 new version life is easy and it doesn't throw NULLReferenceException error.

            Product objProduct = new Product();

            if (string.IsNullOrEmpty(objProduct.ProductName))


                objProduct = null;


            // Before C# 6.0

            WriteLine(objProduct != null ? objProduct.ProductName : "Old Product"); 

            // from C# 6.0 onwards

            WriteLine(objProduct?.ProductName ? ? "New Product"); 

           public class Product


              public string ProductName { get; set; } = string.Empty;



4. Exception Filter

Exception filter allows you to show/log different exception messages based on your choice or requirement.

For eg - You want to show different exception messages to your internal and external users. How you will achieve this. Before C# 6.0 it was not possible, but now in C# 6.0, this feature allows you to do the same.

            string user1 = "user";

            string user2 = "admin";

            string loggedinUser = string.Empty;



                if (loggedinUser == admin)


                    //Some action

                    //Exception occurred




                    //Some action

                    //Exception occurred



            catch(Exception ex) when(loggedinUser == admin) // exception for admin


                WriteLine("Admin related handling to be done.");


            catch(Exception ex)all other users


                WriteLine("Please contact admin / support");



5. await in catch and finally block

Asynchronous programming in catch and finally

This is the most awaited feature. Before c# 6.0 it was not possible to use async and await within catch and finally block. But now it is possible in C# 6.0. 

        //Asynchronous programming in catch finally

        public async void CalCDevision(int val1, int val2)




                int res = val1 / val2;



            catch (Exception)


                await CatchMethod();




                await FinallyMethod();



        private async Task CatchMethod()


            WriteLine("Exception occured");


        private async Task FinallyMethod()


            WriteLine("Finally Executed");



6. Index Initializer

This feature makes collection initializers more consistent.

Before C# 6.0 Dictionary Initialization syntax is {"Key", "Value"}

But now in C# 6.0 we can write like this - ["Key"] = "Value";

           //Dictionary initialization Before C# 6.0

             var WebPageError = new Dictionary<int, string> {

            { 404, "Page Not Found" }, { 301, "Moved Permanently" },{ 404, "Internal Server Error" }};


           //After C# 6.0

            var webPageError = new Dictionary<int, string>


                [404] = "Page Not Found",

                [301] = "Moved Permanently",

                [500] = "Internal Server Error"



7. Expression-Bodied Function

This feature allows us to write a function as an expression. See below code snippet and you will notice the differences.

       //Before C# 6.0

        public static int AddNumbers(int x, int y)


            return x + y;


        //C# 6.0 onwards

        public static int Add2Numbers(int x, int y) => x + y;


8. String Interpolation

With this new feature of C# 6.0 way to write Format string has been completely changed.

          string message = "Hi {0}.";

         string userName="Sample User";

          //Before C# 6.0

          string output = string.Format(message, userName);



          //C# 6.0

          message = $"Hi {userName}";




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)]="".


Azure stuff

by Admin 12. July 2016 12:39

Azure Service Fabric is a distributed systems platform that makes it easy to package, deploy, and manage scalable and reliable microservices and containers. Service Fabric also addresses the significant challenges in developing and managing cloud native applications

Microservices - also known as the microservice architecture - is an architectural style that structures an application as a collection of loosely coupled services, ...


Blob: stands for Binary Large Object. Blob is a file of any type and size.

1. Block Blog

2. Page Blog

Blobs are stored in containers and Entity in table




Tag cloud