Serverless .Net Core(2.0) application with AWS Lambda: Step by step guide

Neel Bhatt

aws15Note – You can find the source code of my sample application here.

Amazon has recently announced the .NET Core 2.0 AWS Lambda runtime.

In this post, we will see how to create Server less .Net Core 2.0 application using AWS Lambda.

Let us first see what is Serverless computing?

  • Serverless computing allows you to build and run applications and services without thinking about servers
  • Serverless applications don’t require you to provision, scale, and manage any servers
  • You can build them for nearly any type of application or backend service, and everything required to run and scale your application with high availability is handled for you
  • Building serverless applications means that your developers can focus on their core product instead of worrying about managing and operating servers or runtimes, either in the cloud or on-premises.

Let us start Step by step guide.

prerequisite:

View original post 466 more words

Advertisements

Best practices on Rest API client in Dotnet ecosystem

Howdy Readers,

Today I’m going to write something about HttpClient inspired by ASP.NET community standup. The popularities of microservices and REST API’s are on it’s highest peak. Which makes us using HttpClient the most. While you are calling rest API using HttpClient, you need to be aware of few most important things.

  1. Do not create a new instance of HttpClient class for each request. Creating new object will create two problems.
    • Each time the new connection will create a new connection pool for each request and it is a very costly operation as it includes 3-way handshake(HTTP) or even costlier TLS handshake(HTTPS)
    • The second issue with this is it may lead to socket exhaustion because in whichever operating system environment you are in, you have limited sockets. You may think that you will dispose the object of HTTP client and you might not have parallel users equivalent to no of sockets(64K) but there is a catch here. Once you dispose of the object, socket does not get freed up immediately. The different operating system takes the different amount of time to free up the sockets(say 3-5 seconds). Hence this may lead you to reach handle limit.
  2.  Do not create a single instance(static or singleton) of HttpClient. If you read the point one, you may conclude on creating the single instance of HttpClient because of it is thread-safe. This is said to be a more efficient way of creating HttpClient but it also has a serious issue. It will keep the connection open for a very long time. This has issue like
    • It may lead to not respecting load balancing. What I mean by this is if your connection is opened with server X then all requests from your application will go to the same server and other servers might be in idle state. This may be a big problem when you are one of the highest load generator client of that API.
    • The bigger problem comes when API uses things like Online-Offline (Blue-Green) deployment. On the toggle of API, Open connection with server keeps sending a request to it although it might have become an offline server.
    • You might have some default header which you might not want to share between different clients.

This Leads to a conclusion that keeping either single or transient connection can cause many issues. It is always recommended to create connections smartly, some of the examples might be to create client per request kind and also keep refreshing the connection over a period of time. There can be many such solutions but use it smartly according to your need.

Image detection bot using Microsoft Vision API : Step by step guide

Neel Bhatt

bot9Note – You can find the source code of my sample application here.

In my previous post about Bots, I have explained how to use FormFlow to create attractive selection box in bots which you can find here.

In this post, I will explain how to create Image detection bot using Microsoft Vision API.

Let us see how to create Image detection Bot application using Visual Studio 2017.

prerequisite:

Also if you want to have Bot Application as a template then as a workaround just download this  (download would start once you click on the link) project and put the extracted folder into below location:

C:UsersYourNameDocumentsVisual Studio 2015TemplatesProjectTemplatesVisual C#

Once this is done, you can see Bot Application template as shown below:

bot1Click on Bot Application and then it will create a sample project…

View original post 1,130 more words

Terraform, VPC, and why you want a tfstate file per env

charity.wtf

Hey kids!  If you’ve been following along at home, you may have seen my earlier posts on getting started with terraform and figuring out what AWS network topology to use.  You can think of this one as like if those two posts got drunk and hooked up and had a bastard hell child.

Some context: our terraform config had been pretty stable for a few weeks.  After I got it set up, I hardly ever needed to touch it.  This was an explicit goal of mine.  (I have strong feelings about delegation of authority and not using your orchestration layer for configuration, but that’s for another day.)

And then one day I decided to test drive Aurora in staging, and everything exploded.

Trigger warning: rants and scary stories about computers ahead.  The first half of this is basically a post mortem, plus some tips I learned about debugging terraform outages.  The second half is about why you should…

View original post 2,162 more words

Optimizing Identity Tokens for size

leastprivilege.com

Generally speaking, you want to keep your (identity) tokens small. They often need to be transferred via length constrained transport mechanisms – especially the browser URL which might have limitations (e.g. 2 KB in IE). You also need to somehow store the identity token for the length of a session if you want to use the post logout redirect feature at logout time.

Therefore the OpenID Connect specification suggests the following (in section 5.4):

The Claims requested by the profile, email, address, and phone scope values are returned from the UserInfo Endpoint, as described in Section 5.3.2, when a response_type value is used that results in an Access Token being issued. However, when no Access Token is issued (which is the case for the response_type value id_token), the resulting Claims are returned in the ID Token.

IOW – if only an identity token is requested, put all claims into the token. If however…

View original post 210 more words

Introducing Jasper — Asynchronous Messaging for .Net

The Shade Tree Developer

IMG_1017

For my take on when you would use a tool like Jasper, see How Should Microservice’s Communicate?

“Jasper” is the codename for a new messaging and command execution framework that my shop has been building out to both integrate with and eventually replace our existing messaging infrastructure as we migrate applications to Netstandard 2.0, ASP.Net Core, and yes, adopt a microservices architecture. While we’ve been working very hard on it over the past 6 months, I’ve been hesitant to talk about it too much online. That ends today with the release of the first usable alpha (0.5.0) to Nuget today.

We’ve already done a great deal of work and it’s fairly feature rich, but I’m really just hoping to start drumming up some community interest and getting whatever feedback I can. Production-worthy versions of Jasper should hopefully be ready this spring.

Okay, so what problems does it solve over just…

View original post 1,242 more words

How Should Microservice’s Communicate?

The Shade Tree Developer

We do quite a bit of distributed development and inter-service messaging at work. Some of this is done through exposing HTTP services. For asynchronous messaging between systems, my shop uses FubuMVC and its .Net Core replacement “Jasper” as a service bus (translate “Jasper” to “MassTransit” or “NServiceBus” when you read this). This blog post is a draft of our architectural team’s advice to our teams on choosing which option to use for their projects as part of our nascent microservice architecture approach. If any of my colleagues see this and disagree with me, don’t worry because one way or another this is going to be a living document and you’ll get to have input to this.

Microservices will generally need to send or process messages from other microservices or clients. To that end, it’s worth considering your options for inter-service communication.

We commonly use either HTTP services or the Jasper/FubuMVC…

View original post 722 more words