.NET Core Test Explorer

by Admin 25. December 2017 08:15

Plugin name: .NET Core Test Explorer

Install Steps: 

  1. Go to the extensions market place in VS code and search for ".NET Core Test Explorer"  and install.

Setup steps:

  1. Go to VS Code > File > Preferences > Settings > scroll to “Code Actions on save” as shown in the screenshot below & Click on “Edit in Settings.Json”


  2. Add your test project location from your solution as highlighted in the screenshot. (Eg: "dotnet-test-explorer.testProjectPath": "/tests/ValuesAnalyser.Api.Tests/ValuesAnalyserAPI.Tests.csproj")
  3. Close and open VS code
  4. Ctrl + Shift + P to search for the .NET Core Test Explorer as below


  5. Once selected, VS code will start discovering the tests


  6. Now you can see all the tests and the highlighted "Run Test" & "Debug Test"
  7. Alternately you can right click on the test and either run or debug (make sure you place a break point (smile))
  8. Once the tests pass you should be able to see the green ticks & the ticks on top of the [Fact]


 

NOTE:  I had the some issues running the tests and here are the steps to resolve

  1. If you got any issues like access to the file / folder denied in the tests. Please run these scripts 

          sudo chown -R vagrant:vagrant /home/vagrant/Desktop/projects/values-analyser-services/

          ls -lah /tmp/NuGetScratch/lock

          rm -rf /tmp/NuGetScratch/

  2. If the tests are not getting discovered, rebuild the Api
    Eg: for ValuesAnalyser Api
    Go to the API location: /home/vagrant/Desktop/projects/values-analyser-services/src/ValuesAnalyser.Api>sudo dotnet build
                 

     

 

 

Plugin name: Prettier formatter for Visual Studio Code

Install Steps: 

  1. Go to the extensions market place in VS code and search for "Prettier - Code formatter"  and install.

Setup steps:

     1. CMD + Shift + P -> Format Document
    OR
     1. Select the text you want to Prettify
     2. CMD + Shift + P -> Format Selection

If you are getting the ugly red underlines >  run "dotnet restore" in all your projects

 

If we want to have single quotes instead of double quotes,

Go to VS Code > File > Preferences > Settings > Go to Prettier code formatter & tick the checkbox as highlighted in the screenshot below


If we want to auto-format on save or on paste,you can modify the settings.json file as below

There are other formatting features available which are available on this page above...

Tags:

VSCode tips

by Admin 17. December 2017 05:53

VS Code help

Cmd Pallete for formatting etc: Ctrl+Shift+P

 

Lint

From ClientApp directory in the terminal > ng lint prjName --fix

Tags:

Set Default datetime in C# for SQL server

by Admin 23. September 2017 01:24

Set Default datetime in C# for SQL server

var defaultDatetime = System.Data.SqlTypes.SqlDateTime.MinValue.ToString();

Tags:

Web Api Questions

by Admin 17. May 2017 10:47

What is Web API?

WebAPI is a framework which helps you to build/develop HTTP services.

Why is Web API required? Is it possible to use RESTful services using WCF?

Yes, we can still develop RESTful services with WCF. However, there are two main reasons that prompt users to use Web API instead of RESTful services.

  • Web API increases TDD (Test Data Driven) approach in the development of RESTful services.
  • If we want to develop RESTful services in WCF, you surely need a lot of config settings, URI templates, contracts & endpoints for developing RESTful services using web API.

Advantages of Web API are:

  • OData
  • Filters
  • Content Negotiation
  • Self-Hosting
  • Routing
  • Model Bindings

The latest features of ASP.NET Web API framework v2.0 are as follows:

  • Attribute Routing
  • Cross-Origin Resource Sharing
  • External Authentication
  • Open Web Interface NET
  • HttpActionResult
  • Web API OData

How can you handle errors in Web API?

Several classes are available in Web API to handle errors. They are HttpError, Exception Filters, HttpResponseException, and Registering Exception Filters.

What are main return types supported in Web API?

A Web API controller action can return following values:

  • Void – It will return empty content
  • HttpResponseMessage - It will convert the response to an HTTP message.
  • IHttpActionResult - internally calls ExecuteAsync to create an HttpResponseMessage
  • Other types - You can write the serialized return value into the response body

What is REST?

REST is architectural style. It has defined guidelines for creating services which are scalable. REST used with HTTP protocol using its verbs GET, PUT, POST and DELETE.

Tell me the code snippet to show how we can return 404 errors from HttpError?

Code for returning 404 error from HttpError

string message = string.Format(“TestCustomer id = {0} not found”, customerid);

return Request.CreateErrorResponse(HttpStatusCode.NotFound, message);

 

How to handle errors in Web API?

Several classes are available in Web API to handle errors. They are HttpError, HttpResponseException, Exception Filters, Registering Exception Filters.

 

WebAPI is used for developing HTTP services

Who can consume WebAPI?

WebAPI can be consumed by any client which supports HTTP verbs such as GET, PUT, DELETE, POST. As WebAPI services don’t need any configuration, they are very easy to consume by any client. Infact, even portable devices like Mobile devices can easily consume WebAPI which is certainly the biggest advantages of this technology.

 

Web Api Versioning

Query String

URL

Headers

Azure Questions

What is Cloud Computing?

Cloud computing is a term referred to storing and accessing data over the internet. It doesn't store any data on the hard disk of your personal computer. In cloud computing, you are allowed accessing data from a remote server.

It is the use of servers on the internet to “store”, “manage” and “process” data.

What is Microsoft Azure?

Azure is a cloud computing platform which was launched by Microsoft in Feb 2010. It is a highly flexible cloud platform that offers development, data storage, service hosting, and service management.

Roles are a very important concept in Windows Azure, and learning them is the base for further programming.

Three types of roles in Windows Azure are:

  • Web Role: It is used to deploy website by using language which is supported by the IIS platform customized to run the web apps.
  • Worker Role: It helps you to execute the process that runs in the background.
  • VM Role: It helps you to schedule the windows services and tasks. (a combination of Web Role & Worker Role.)

Why should you use Azure CDN? Azure CDN should be used to reduce load time and bandwidth as well as speed the responsiveness.

Name some important applications of Microsoft Azure

Most important application of Microsoft Azure are:

Infrastructure Services, Mobile Apps, Web Applications, Cloud Services, Storage, Media Services, etc.

What is Azure as PaaS? PaaS is a computing platform that includes an operating system, programming language execution environment, database, or web services. Developers and application providers use this type of Azure services.

Explain Cmdlet command of Microsoft Azure A cmdlet is a command which is utilized as a part of the Microsoft PowerShell environment. The cmdlet is called by the Windows PowerShell to automate the scripts which are in the command line.

What is the use of Azure Active Directory?

Azure Active Directory is an identity and access management system (IAM). It is very much similar to the active directories. It allows you to grant your employee in accessing specific products and services within the network.

What is HDInsight in Microsoft Azure?

HDInsight is a cloud service which that makes it easy. It is fast and cost-effective to process a massive amount of data using with the help of open-source frameworks like Spark, Hadoop, Hive, Storm and R. HDInsight offers various type of scenarios which includes ETL, data warehousing, and Machine Learning

Explain the term 'service fabric' in Azure

Service fabric is a middleware platform which gives more scalable outcome. It mostly renders with a more managed and reliable enterprise.

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. Developers and administrators can avoid complex infrastructure problems and focus on implementing mission-critical, demanding workloads that are scalable, reliable, and manageable. Service Fabric represents the next-generation platform for building and managing these enterprise-class, tier-1, cloud-scale applications running in containers. https://docs.microsoft.com/en-us/azure/service-fabric/service-fabric-overview

Name the types of web application which can be deployed with Azure

ASP.Net, PHP, WCF are a type of web application which can be deployed with SQL Azure.

Explain the service definition file The course service definition file (.csdef) defines the service mode. It includes a number of roles.

Name the services which are used to manage resources in Azure

  • Application Insights
  • Azure Portal
  • Azure Resource manager
  • Log Analytics

What are the important drawbacks of using Microsoft Azure?

  • Cloud computing is not possible if you are not able to connect to the Internet.
  • Azure is a web-based app which needs a lot of bandwidth to download, as do large documents.
  • Web-based applications can sometimes be slower compared accessing similar software program on your desktop PC.

What is MOSS? Microsoft SharePoint Server (MOSS) that consist of a complete version of the portal platform. It allows a user to manage, share and even create the document.

What is the use of VNET?

VNet is a representation of your own network in the cloud. It logically isolates your instances launched in the cloud, from the rest of your resources.

What are stateful and stateless microservices for Service Fabric?

Explanation: Service Fabric enables you to build applications that consist of microservices. Stateless microservices (such as protocol gateways and web proxies) do not maintain a mutable state outside a request and its response from the service. Azure Cloud Services worker roles are an example of a stateless service. Stateful microservices (such as user accounts, databases, devices, shopping carts, and queues) maintain a mutable, authoritative state beyond the request and its response. Today’s Internet-scale applications consist of a combination of stateless and stateful microservices.

 

What is Azure Functions?

Azure Functions is an event driven, compute-on-demand experience that extends the existing Azure application platform with capabilities to implement code triggered by events occurring in virtually any Azure or 3rd party service as well as on-premises systems.

Azure Functions is a tool in the Serverless / Task Processing category of a tech stack.

Auto Scaling: There two type / workflow of Scaling:

·       Scale Up (Vertical Scaling)

Make it bigger. Its means Get More size of CPU, Memory, Disk space etc. You scale up by changing the pricing tier of the App Service plan that your app belongs to.  Ex: Increase the RAM size from 2 TB to 10 TB.

·       Scale out (Horizontal Scaling)

Add more Instances. It’s like upgrading the capacity of the app / server by creating/ adding more instances of same size. Using Load balancer, you can manage all request coming from end users. Suppose your Sever has 10 GB RAM, 200 TB HDD space, 10 core etc. so while scaling out this server you will create more instances of servers with same configuration.

Horizontal scaling Vs.  Vertical Scaling

Here are few points which are important when we think about going with Horizontal scaling or Vertical Scaling.

·       Scaling up require down time, in this case you need to upgrade server’s configuration like RAM, memory, CPU etc. so while upgrading this configuration your server require downtime. Once you are done with update, restart of server is required.

·       Scaling up will Increase performance but not availability, because its only one instance if it can go down anytime.

·       Scale Out not require down time, in Scale out its crates new instances of server it don’t touch to existing instance so no downtime require.  

·       Scale Out, Increase performance and availability as well. When you increase no of instances and handle load / request using load balancer it’s increase performance of server but also increase availability as well.

Azure Service Busis a fully managed multi-tenant cloud messaging service (MAAS). It is brokered messaging system. Applications and services can communicate with each other using messages via Service Bus. Message consists of two parts; message properties and message payload. Message properties is a dictionary of values against property keys. Message payload is in binary format, which can contain JSON, XML, or text data.

Architecture

Azure Service Bus offers three types of communication mechanisms; queues, topics and, relays. Queues and Topics, facilitate one-directional communication. Messages will be stored until they are consumed. Each message in Queue is received by a single recipient. Topic can have multiple subscriptions for multiple receivers. Subscriptions can choose to receive messages based on parameters. Messages from Queues and Topics can be accessed using Service bus-defined messaging APIs or REST APIs. SDKs are also available for other languages. Unlike Queues and Topics; Relays provide bi-directional communication and does not store messages.

To use these messaging services, user must create namespace under Azure subscription. A namespace can be visualized as a logical container for messaging components. Multiple Service Bus components (queues, topics and relays) can reside within a single namespace.

 

 

Why Service Bus

As Azure Service Bus is fully managed service, scaling and availability will be taken care by Azure team. It is integrated with other Azure services like, Event Grid, Logic Apps, Stream Analytics etc. Azure Service Bus provides reliable and secure asynchronous message communication platform along with facility of delayed processing of events or data. Shared Access Signatures (SAS), Role Based Access Control (RBAC) and Managed Service Identity (MSI) protocols are supported by it. Service Bus also supports client libraries for .NET, Java, JMS.

Tags:

Install PostMan in Linux / Ubuntu

by Admin 16. April 2017 00:40

Tags:

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?
FN::GetAtt

What language are cloud formation templates written in?
JSON

 

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
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?
ChangeMessageVisibility

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

 

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

Protocols > HTTP, HTTPS, EMAIL, EMAIL-JSON, AMAZON SQS, Application
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.

 https://www.lidl.co.uk/en/Non-Food-Offers.htm?id=265

 

 

Tags:

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)

        {

            services.AddMvc()

                    .AddJsonOptions(options =>

                    {

                        options.SerializerSettings.ContractResolver =

                            new CamelCasePropertyNamesContractResolver();

                    });

        }

Tags:

AWS Steps to setup Serverless & Lambda

by Admin 11. February 2017 08:04

AWS Command Line Interface

https://aws.amazon.com/cli/

AWS Toolkit for Visual Studio

https://aws.amazon.com/visualstudio/

Install NodeJS & Git Bash

install node js tools for visual studio

https://www.visualstudio.com/vs/node-js/

Install serverless globally

The commands are here https://serverless.com/

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

https://marketplace.visualstudio.com/items?itemName=MadsKristensen.MarkdownEditor

Next

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

provider:

  name: aws

  runtime: dotnetcore1.0

  stage: dev

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

  credentials:

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

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

Note:

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

#configuration

 #AWS config

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

awsAccessKey:PASTE_YOUR_ACCESS_KEY_HERE

awsSecretKey:PASTE_YOUR_SECRET_KEY_HERE

accountId:PASTE_YOUR_ACCOUNT_ID_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

package:

  artifact: bin/release/netcoreapp1.0/publish/deploy-package.zip

  exclude:

  - .git/**

Now right click build.ps1 file and open with powershell

Now run this command 

./build.ps1

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

C:\VENKAT\Learning\AWS\Dev\serverless-Sample1\bin\release\netcoreapp1.0\publish

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

C:\VENKAT\Learning\AWS\Dev\Serverless\bin\release\netcoreapp1.0\publish

The code is successfully deployed on the server now.

Now go to the AWS Lamda 

https://eu-west-2.console.aws.amazon.com/console/home?region=eu-west-2#

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

https://eu-west-2.console.aws.amazon.com/apigateway/home?region=eu-west-2#/apis

 

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 

 

Now 

https://eu-west-2.console.aws.amazon.com/apigateway/home?region=eu-west-2#/apis/ayd0i0b484/resources/g21af8/methods/GET

Make sure you deploy

https://ayd0i0b484.execute-api.eu-west-2.amazonaws.com/dev/users/create?request=test

 

Deploy to live AWS account

serverless deploy

UFunction deployed!

http://api.amazon.com/users/update

 

Janisha-GBRL01483M17.pdf (566.60 kb)

Vijay-GBRL01481M17.pdf (564.19 kb)

Tags:

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

Deploy 

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

 

 

 IAM 

 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

 

 S3

 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>

 

Tags:

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

Tags:

The launch of the uk replica watches new timepiece series undoubtedly symbolizes the replica watches history of the brand, and the classic hublot replica watches design explains the mission of the replica watches uk brand's precision watchmaking.

TextBox

Tag cloud

    RecentPosts