AWS Cognito Service in Asp.net Core 3.1 Application


AWS Cognito Service is the user management and authentication product of Amazon Cloud. It provides the plug able login functionality for any type of application. It also provides the users to sign in through external federated identity providers like Facebook, google, Login with Amazon, Sign with apple etc.

Advantages of this services.
1. We don’t have to write code for user management functionalities.
2. Free for the first 50,000 monthly active users.
3. It will provide centralize authentication.

What are the steps to create this services

1. Create a User Pool on Amazon web site

2. Create an App Client

3. Go to the domain and give some domain name

4. Go to the App Clients in general Setting and Create it like this.
You will get the Client Id and App client secret which one is required in code configuration.

5. Go to the app client setting and configure for localhost demo testing like this

cognito1 Continue reading

Creating Serverless Microservices with AWS Lambda and ASP.NET Core


As you know Micro service is one alternative approach to write Web API method. There are so many ways to create the micro-service. But in this post i m going to write creating micro service using Amazon Web Service(AWS) Lambda ToolKit on Asp.net Core

what is the Serverless Microservices ?

Serverless microservices are deployed within a serverless vendor’s infrastructure and only run when they are needed by the application. Depending on the size of a microservice, it may also be broken up into even smaller functions.

It doesn’t means that there will be no server. There will be cloud vendor’s server.

AWS use the Lamda and API gateways for this functionalities.

What are the advantages of this approach ?

1. You don’t have to pay for idle server time. So it will save huge deployment cost
2. If you have small application like POC and you are going to use that application for specific time interval then this approach will good. It will save huge money.
3. On demand we can scale the application, since it is on cloud.
4. It is give good performance as compare to monolithic approach.

How to create Serverless microservice with AWS

Step 1: Install the AWS Toolkit Extension as given below

Step 2: Create the Web Api Serverless Project like this

This template will add the all the requited dll and required files for us to making serverless microservice

Step 3: Add some Empty API controller in Controller folder and write some test method like this



using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Net.Http;

namespace AWSServerless3.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class TestController : ControllerBase
    {
        // GET: api/Test
        [HttpGet]
        public IEnumerable<string> Get()
        {
            return new string[] { "value1", "This is from Test Controller" };
        }
        //external
        [HttpGet]
        [Route("external")]
        public string External()
        {
            try
            {
                HttpClient client = new HttpClient();
                var requestTask = client.GetStringAsync("http://www.chandradev819.wordpress.com");
                requestTask.Wait();
                return "external connectivity PASS";
            }
            catch (Exception e)
            {
                return "external connectivity FAIL";
            }
        }


    }
}

Add one more controller i.e EmpController



using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;

namespace AWSServerless3.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class EmpController : ControllerBase
    {
        // GET: api/Emp
        [HttpGet]
        public IEnumerable<string> Get()
        {
            return new string[] { "value1", "This is from Emp Controller" };
        }
    }
}

Step 4; Build the application and run on local machine before deployment

Now We are good to deploy on AWS. Now we have to create the profile on

https://aws.amazon.com/

Configure AWS user credentials as given below post

https://docs.aws.amazon.com/toolkit-for-visual-studio/latest/user-guide/credentials.html

Step 5: After successfully configure, Right click on Solution explores and deploy the application like this

Now publish the application on AWS Cloud like this

After published we will get the URL like this

Now our services has been deployed as Server less microservice on AWS Cloud. We donot have to do any thing.

Now we are ready to use the microservice on our application

Summary

I hope in this small post you might have got clear idea about creating Serverless Microservice using AWS Lambda Toolkit in Asp.net Core application.