#Microsoft – Suraj | Coding Passion Tue, 09 Oct 2018 07:03:49 +0000 en-US hourly 1 https://wordpress.org/?v=4.9.8 .Net Core, The Beginning! /net-core-the-beginning/ /net-core-the-beginning/#respond Sun, 06 Aug 2017 15:28:19 +0000 /?p=760 What is Asp.Net Core

Asp.Net Core is completely re-written prior to earlier versions works on .Net framework. Asp.Net was developed with main focus to make it cross-platform! Yes Asp.Net core is now cross platform. It has gained popularity in quick time for modern day web development. One go cloud development with configurations made easy, with self hosting process with IIS and many more features added to Asp.Net core which makes it stand tall!

Cross Platform!

Yes! you read it right, Asp.Net core is now cross platform. The Asp.Net core CLR now has now WPF & winforms. It is built to code once and run on any platform. We can now have the .Net framework installed on Linux, Unix or OSX.

.Net Core CLR has joined the open source community and is on github. Anyone can contribute now on github for the .Net Core. Asp.Net Core applications can run both on .Net earlier frameworks and also on .Net core, which puts a great benefit for the developers. .Net Framework 4.6 is the same .Net we have been using and continue to develop the same way. .Net Core gives a platform to generate cross-platform solutions. But .Net 4.6 is stable and .Net core is under progress.

Merged stack MVC & Web API

Now this seems interesting. What? MVC & Web API merged!! Yes it is, in Asp.Net core we will have the merged stack of MVC and API and moreover Webforms is completely gone! Earlier we were required to add more than one Web project, one for MVC and one for Web API. But in Asp.Net core, we need to have only one project.
Multiple inbuilt tools are being used with .Net Core to build web applications with ease like NPM used for tools support, Client side support using Bower, Grunt & Gulp for building automatically, & as usual Nuget for .Net packages.

.Net Core application with Command Prompt & VS Code

Once we have installed .Net core framework in our system, since it is open source the .Net Framework can be accessed and projects can be maintained through command prompt.
Open command prompt, and hit “dotnet”. It will result the entire information of the .Net framework.

To create a new project using the dotnet templates, using scaffolding in VS IDE. The same scaffolding is also possible in the command prompt. With the command, “dotnet new”. This creates the scaffolding and restores the packages required if not exist.

Then the scaffolding templates:

Here we see multiple templates
Choose one of the templates setting the path where the project needs to be added. Lets create a console application as of now in one of our drives. To add a new console application, the command goes like below:

Here a new project is created, a console application for “Hello World”. Then when you run, you get namespaces missing error and navigating into the directory, you find the bin and obj folders go missing. Thus the error shown below:

Thus, restoring the packages solves the issue.
“dotnet restore”
This resolves and restores the required default packages for the console application.
Then build the project in order to ensure the code is errorless.
“dotnet build”
After build succeeds, then run the project to get the out put.
“dotnet run”
Output goes as below:

The same can be achieved in the terminals of Linux OS & Mac OS, just .net Core framework needs to be installed on the OS, which is why .Net core is developed to make it cross platform.
Upcoming articles we will look into the more details of the dotnet core. Creating Web applications using .net core and the MVC6.

]]>
/net-core-the-beginning/feed/ 0
Azure Automation using Powershell /azure-automation-using-powershell/ /azure-automation-using-powershell/#respond Mon, 31 Jul 2017 13:02:40 +0000 /?p=747 Introduction

In order to run the Azure, we know the web azure portal where we can modify and manage resources as and when needed. But to manage resources on regular basis, logging into the Portal each time is a hectic job. So automation can solve maximum problems for us. For the automation, we write scripts that keep running in order to ensure the valid logic gets executed.

For the Azure to be automated, we need the azure SDKs. Download the SDKs if not added already. To download the SDK, navigate to the Download SDKs.
There are options for various tools and languages supported by Azure up till date like Java, Visual Studio, Node JS, PhP, Python, RUBY, etc.
We are here interested for Powershell command line tools.

Once downloaded, click and follow the installation rules and then the azure contents would work with Windows Powershell.

Once the powershell azure sdk is installed, open the Powershell with administrator rights.
Then, the first thing we need to is Login with azure credentials and connect to Azure. The command is

> Login-AzureRmAccount

This opens up the Microsoft Azure Login window. Add the user name and password and login.

After the login, in the powershell window, we can see the details of the subscription.

Now, if suppose you have multiple subscriptions and want to select a particular subscription, then the below command works out:

//To fetch the subscriptions
 > GetAzureRmSubscription
//To select the particular subscription
 > GetAzureRmSubscription -SubscriptionName SubName | Select-AzureRmSubscription

To get the current subscription details for which we are working on, then the shell script goes like:

//To get the current context of the azure subscription being used
 > Get-AzureRmContext

The above few syntax have AzureRm. Now the “Rm” here means ‘Resource Management’

Getting the list of VMs in the Azure resources under the subscription:

> Get-AzureRmVm //Gets the list of VMs under the subscription


The above image shows, we have a single VM with Resource name “VS2015”. There are other information as well like, disk size, type, OS, etc.

Now to stop the Azure VM, we need to have the below running script:

> Stop-AzureRmVm -ResourceGroupName VS2015 -Name VS2015


This way we can use the powershell script and connect to Azure in order to use and create Azure services without using the portal. In the upcoming articles we will look into creating other services through Powershell.

]]>
/azure-automation-using-powershell/feed/ 0
Create your first VM in Azure /create-your-first-vm-in-azure/ /create-your-first-vm-in-azure/#respond Mon, 24 Jul 2017 08:40:02 +0000 /?p=738 Introduction

Cloud computing can be a complex term now a days, as there are already many services that can run on Cloud. Services like Data mining, Machine learning, creating virtual machines, host APIs for mobile applications and many other endless services.

Microsoft Azure is an open and varied platform, which allows you to choose from a variety of Operating Systems, programming languages. When you build an application in Azure, we will be using specific types of services that would be running on one or more servers on the cloud. We can configure and create Paas services like SQL databases, NoSQL databases, Document DB. Creating app services, and automating the azure services using powershell scripts is what triggers developers to use this. Here in this article, we will look into how to create a Virtual Machine and why to create a VM on Azure.

What is and Why use Virtual Machine?


A virtual machine according to wikipedia, is an emulation to computer system, where emulation would mean to enable a computer system to behave like another computer system (a job of an emulator which may be physical or virtual). A virtual machine can be used on Azure platform on OS like Windows and Linux. The VMs on Azure are highly efficient, high-scale, secure and run on a virtual environment on windows server.

Creating a VM on Azure

Once, you are ready with the Azure subscription and up and running Azure portal. Login to the Azure portal and you see the dashboard.
The dashboard on the portal displays all the services added to the Azure like below:

Click on the New (+) tab & you find another tabbed window displaying all the categories of services provided by Azure. The Virtual Machine is under the Compute service. The options would look like below:

The summary also shows about the sub services. Services like Windows Server Datacenter, which is effective, application focused and user friendly. Ubuntu Server 16.04 Transport Layer Security. Sql server 2016 with SQL server installed on the VM. A normal VM instance, a VM scale which can be used to deploy and also manage identical sets of VMs using a single image and many other compute services.
We would be creating here, a Windows Server Datacenter. Clicking on that option will ask user to configure the Virtual Machine.

Once the configuration is added and OK is clicked, it asks the user for selecting the size of the VM. Remember, the pricing will vary based on the high end configured size (if chosen). Here, I am choosing the minimum configuration DS1_V2 Standard with 1 core. Based on the application we can manipulate the configuration. That is the scaleable option provided by Microsoft Azure. We can anytime scale up and scale down based on our requirement.
Once done click Ok, then the tab for optional configuration. This is the 3rd step. We can move on and click OK to finalize the purchase and get the VM. Once, VM is ready, click on Connect and it downloads the RDP. Using the same username and password we connect the VM and start using the VM.

Its up and running. We can go ahead and configure IIS and run on the server. You can manage your resources using the dashboard and stop the resource whenever not in use so as to avoid consumption of your credits.

]]>
/create-your-first-vm-in-azure/feed/ 0
Journey to MVP /journey-to-mvp/ /journey-to-mvp/#comments Wed, 06 Jul 2016 07:13:57 +0000 /?p=725 “Somethings in life come at the right time. Keep working and face your failure”

I start with saying, we are all IT professionals struggling and working diligently, burning midnight oil everyday ! We are living in a space where the number is increasing prodigiously. To shine out has become a tough job and a challenge to be gracefully accepted. Our lives cannot be limited to a 6 by 6 cube! We have to come out of it and see the world expanding. We have to match it up and marathon along. Everyday while returning, give a thought what am I doing! who else other than my office space know me! Where do I stand in this mammoth head count!

I started over thinking these when I saw few people around me adding logos to their laptops, to their desks and they were kind of addicted and so proud! The first guy I faced was Mr. Tadit Dash, one of the three Microsoft MVPs from Odisha.. He was my inspiration and his achievements became my desires. I used to read articles and refer the different forums and was unaware of the fact that someday, I will see my articles being read and my answers being referred.

I started writing articles on C-sharp corner, the most friendly and one of the best forums today! The amount of motivation and the support the team provides, will automatically boost you and push you to contribute your learning experiences and share with the world.

The first time I was awarded by C-sharp corner in 2014 as MVP and I was like, wow! I can’t explain the feeling, the one who has experienced knows! The journey continued and again in 2015 I was awarded by C-sharp corner 2nd time MVP. I realized people have started knowing me and acknowledging my work. This meant a lot to me. I then realized the certificates and logo were not only to showcase, it was more satisfaction when people started liking your efforts and appreciating.

As rightly said,

When you desire something & you know not where you are heading, any road will get you there!

The next dream was to become Microsoft Most Valuable Professional.mvp1
It was July 1st, I had nominated myself in May and was curious to get the results, if my efforts were good enough to let me this recognition. When the mail got triggered into my mail box, I was on the top of this world. Yes, I can now proudly say I have achieved something in this 2.6 years span of my IT career. Now I can be distinguished and at least recognized among the mass.

People now who wonder, if they can, I would say yes you can! Just Go for it!

Ideology & Effort

Now comes the best part, the path to be chosen.  Just one word would be enough SHARING . Share what you learn with the world. There are people who would be struggling to resolve something as you have undergone! Thus, Be selfless!

Sharing is not enough, sharing with dedication and with sincerity is utmost important. We cannot go ahead and share anything. Share valid content and worthy to read contents in a readable format is very essential! This will come with time and with writing. Thus Be patient!

Before sharing another important factor that plays a role is LEARNING.  Start the learning phase and push yourself to the deadliest possible level while learning and expansion of your knowledge. Our IT field requires the knowledge to be updated and extensive as well! Thus Be a ruthless learner!

Guru play a very important role in guiding you through life. In my phase, I had Gurus. You follow them, they guide you, their success becomes your happiness and your aim! They are the happiest people when they see you supersede them. Chose your Guru in order to excel. Thus Be a smart chooser!

Not everyone is confident and comfortable enough to speak and share in conferences. The days have gone friends! Be open, be an extrovert now! The world has grown, burn your fear and stand out and face the crowd. I thank my community MSDC Odisha  through which I could get the platform to face my fear and speak out to the world. Thus, Be a fearless speaker!

A final verdict, without boring much! Whatever you do, do without much self motive and interests. We are humans, we cannot avoid having selfish interest. But that should not be at the cost of choosing a shortcut or hurting someone. Whatever you do, do for the world, the world will then remember you, the world will then praise you, the world will then stand by you.

Someday all our labor will turn to dust!

Yes someday this will happen. People will remember you on your deeds not your codes preserved with a file header in SCM tools.. 🙂 Keep sharing and keep learning!

I blog at @

]]>
/journey-to-mvp/feed/ 4
Sart with C# from scratch- Part 1 /sart-with-c-from-scratch-part-1/ /sart-with-c-from-scratch-part-1/#respond Sun, 15 Feb 2015 10:17:29 +0000 /?p=255 Topics to be covered:-
  • Welcome to C#
  • Working with Variables, Operators & Expressions
  • Understanding your first C# program

Welcome to C#

C# .NET is a powerful language, which is generally called Component Oriented Language. Now we have heard of Object Oriented Language, but what is component oriented language!! Though the difference is fairly blurr and thin, but the reason why this new concept came associated with C# is that a new technique was to be introduced that would develop software combining some pre-existing features (OOP) and welcoming some new components. Some of the components are :

  • Properties
  • Methods
  • Events
  • Attribute(Metadata-Data about Data)
  • Assemblies/Packages

Another major characteristic is introduction to SOC and SOA. SOC is separation of concern via partial classes in c# and SOA is service oriented architecture concept while programming in C#.

Versions in C#

I am mentioning below the versions till date. Data issued from C# Indepth. Please visit or follow the book to know more about the different Versions.

  • C#- version 1
  • C#- version 2: As mentioned, in this version, Generics, Nullable types(), anonynous types & Iterators(blocks) were introduced.
  • C#- version 3: As mentioned implicit typing, object and collection initializers, anonymous types, automatic properties, lambda expressions, extension methods, query expressions were introduced.
  • C#- version 4: As mentioned dynamic typing, optional parameters, named arguments, and generic variance were introduced.
  • C#- version 5: As mentioned asynchronous functions, caller info attributes(This is a very new concept and an interesting one too. These attributes track information about the calling methods/properties and many more.), and a tweak to foreach(one of the example is Parallel.Foreach(with Lambda expression)) iteration variable capture were introduced.

A small incident to share, I always wondered why C sharp?? It is kind of a successor for C++ or what? I always wondered, and I feel many beginner developers would be wondering. Thanks to Wiki the datawarehouse for every bit of concept in the world for letting me know why? Without any delay, straight from the WIKI,

The name “C sharp” was inspired by musical notation where a sharp indicates that the written note should be made a semitone higher in pitch. The sharp symbol also resembles a ligature of four “+” symbols, which thus implies that it is an increment of C++.

Now lets get along and start learning from basics.

Camel & Pascal Case Notations

Every time a developer gets into these concepts, but sometimes beginners like me would wonder what these actually are!!.
Camel case are used for naming fields where as Pascal case are used for naming properties, function names. In Pascal case, the starting letters in the multiword name are capitalized where as in Came case except the very frst letter all are capitalized like below:

  • Pascal Case:- GetSumFromNumbers
  • Camel Case:- getFirstNumber

Working with Variables, Operators & Expressions

Before getting into the variables, lets get into what is an identifier. Identifiers are the names that are used to identify elements in the program. In C#, there are certain conventions to be followed:

  • Only letters are allowed(may it be uppercase or lowercase), digits and underscore(_) characters are allowed.
  • An identifier should always start with a letter.

For example, _getSum, GetSum, Get_sum are valid identifiers. Just to remember or keep in mind everytime that C# is case sensitive so getSum and GetSum are different and give different meanings.
Keywords, there are many keywords that are predefined in C#, for more info on the keywords, follow the below link: C# keywords

Now lets get back to our topic of discussion, variables. A variable is a location with memory or storage location that stores/holds a value. A variable in a program holds a unique name, its like madatory to give it a unique name. A variable holds temporary information. A variable is used to get the value that it holds after assigning. Below I specify the naming conventions to be followed while declaring variables specified by Microsoft .NET team:

  • Underscores are advised not to be used
  • Case differing names for variables should be avoided. Like, abcTest or AbcTest to be used in the same file and same time. This would also mean Identifiers with same name and different case should be avoided.
  • It is advised to start the name with a lowercase. This would be consistent through out as it would lead to easy mantenance.
  • Camel case notations should be used, forexample, abcTest, myVariable, as such.

Declaring Variables is easy and simple. Usually keyword var is used when the type is to be implicitly decided. If any datatype is already used during declaring the vriable, then it is explicitly typed.

var setAge; //implicitly typed
int setAge; //explicitly typed
setAge = 45; //values assigned

As in the above peice of snippet, you can see the statement ends with a semicolon “;” that as simple marks the end or compiler to know that the statement ends here. Equals operator is used to assign the value to the declared variable. C# also uses same the operators that we as developers have been using in the former programming languages (+(plus), -(subtraction), *(asterix/multiplication), /(divide) and also the modulo operator(%)). These are as we know called the arithmetic operators. We cannot apply the arithmetic operations on the datatypes except int(integer type) in a similar way.

int a = 4 + 3;
string b = "4"+"3";
Console.Writeline(a);//Prints 7
Console.Writeline(b);//Prints 43 not 7

However using explicit conversion, string can be converted into integers. For incrementing the values, the increment and decrement operators are also strongly followed in C#.

count= count + 1; //Can be incremented but should not be written like this
count++; //This is how increment should be done

count = count - 1;
count = count--;

Understand your first C# program

As we all know, every program follow a common rule that is Input, Process & Output. Lets have go at it.

using System;
namespace ConsoleDemoApplication
{
    class Program
    {
        static void Main(string[] args)
        {
            string firstName; //Variable for storing string value
            string lastName;

            //Displaying message for entering value
            Console.WriteLine("Please Enter Your First Name");
            //Accepting and holding values in name variable
            firstName = Console.ReadLine();

            Console.WriteLine("Please Enter Your Last Name");
            lastName = Console.ReadLine();

            //Displaying Output
            //{0}{1} take the variable names that are assigned during the runtime by the user
            Console.WriteLine("Welcome {0} {1} in your first C-sharp program", firstName,lastName);

            //Holding console screen
            Console.ReadLine(); 
        }
    }
}

When we run the above program, we get the below output. I am showing the output step wise, so that you get to know the importance of the Console.WriteLine & Console.ReadLine

.output1 As we see in the image, the console window opens up when the project runs and asks for the first name as we see in the program first comes Console.WriteLine(), then when user enters the name Console.ReadLine(), plays its role and stores it in the variable memory firstName.

output2 As we see in the image, the console window opens up when the project runs and asks for the last name as we see in the program first comes Console.WriteLine(), then when user enters the name Console.ReadLine(), plays its role and stores it in the variable memory lastName.

output3  Now when a final enter is pressed by the user with curosity to know what the program gives! Yes it gives the desired out put. It concats the variables where the names/values entered by the user are temporarily stored in memory. {0} {1}, this actually contain the values entered by the user when asked and as mentioned concats the input and displays the full name as the output. This could also have been achieved by using the “+” operator like: 

string fullName = firstName + " " + lastName; //+ operator concats the strings
Console.WriteLine("Welcome {0} in your first C-sharp program", fullName);

There are many libraries that may be used in your program. These libraries need to be mentioned at the top of your program i.e. which is called Namespaces and they are used using a using keyword. 😀 Yes so many use…!!

When on the console window, something needs to be displayed, Console.WriteLine() is used and when we need to take the Input from the user and store in memory, Console.ReadLine() is used. This is a simple and basic difference. The {0} used in our program, acts as asimple placeholder where the dynamic values are used by specifying the argument at the end. The many the arguments, the many the placeholders to be used.

Conclusion

Thanks guys for having patience and reading through. This is what I could cover in the first part and will continue some more interesting topics in the second part. Lets learn Lets explore and Lets share…

Any suggestions and corrctions are humbly accepted as we all keep learning at every step.
Follow the C# 6 New Features for more info on the upcoming version C# 6.

Refrences

CP

]]>
/sart-with-c-from-scratch-part-1/feed/ 0