Saturday, August 28, 2021

Learn C# from Scratch Guide (Zero to Dev with linked tutorials and comprehensive code projects!)

I wanted to create a way for anyone to pickup C#, .NET development, and Visual Studio on their own (or with help of a mentor) for free and see below for the GitHub repository with full projects with solutions, homework, and pre-requisites to get started on your own with videos you can follow along. There are also bonus content linked to learn Agile, Scrum, Git, and more! See below:

https://github.com/KetchupOnMyKetchup/LearnCSharpBase

Saturday, April 25, 2020

Binary Trees Traversal Recursive vs. Iterative



Binary tree - Computer Science Wiki
Photo reference: https://computersciencewiki.org/index.php/Binary_tree

This neat little trick above saved me a lot of pain and is much quicker to get the traversals. Just think preorder = left, inorder = center, postorder = right. Then weave the string from the top left, to the bottom, to the center, and around until you get to the top right. Wherever the string would 'hook' into a line, write down that number as the next one in that type of traversal.

Given a binary tree, return the inorder traversal of its nodes' values.

Every recursive problem can be done iteratively using a stack. Recursive calls are simply utilizing the call stack that is an inherent part of the programming language. Don't forget to take into account the space the stack/recursive calls take up when doing the O notation for space!

Recursive solution:
public IList InorderTraversal(TreeNode root) 
{
	List result = new List();

	Helper(root, result);
	
	return result;
}

public void Helper(TreeNode root, List result)
{
	if (root == null) return;

	Helper(root.left, result);
	result.Add(root.val);
	Helper(root.right, result);
}
Time: O(n)
Space: O(log n) on average. O(n) worst case if tree is one giant linked list going in one direction.

Iterative solution using a stack:
public IList InorderTraversal(TreeNode root) 
{
	List result = new List();
	Stack stack = new Stack();
	
	TreeNode curr = root;
	
	while(curr != null || stack.Count != 0)
	{
		while(curr != null)
		{
			stack.Push(curr);
			curr = curr.left;
		}
		
		curr = stack.Pop();
		result.Add(curr.val);
		curr = curr.right;
	}
	
	return result;
}
Time: O(n)
Space: O(n)

Thursday, March 12, 2020

Learn C# from Scratch Comprehensive Topic List / How much do I need to know to be a Junior C# Web Dev?


I created a syllabus with a list of what I think a great C# .NET web Junior Developer should know and in what order to study.  I wrote this based on someone with no computer science knowledge, background, training, or schooling and how to get them to go from zero knowledge to a working entry level developer. The list is written in a "checklist format" so you can print this if you like and check-off how much progress you have made and how much is left to go!

I wrote this checklist to help out my mentee with being able to see the "light at the end of the tunnel" and know the scope of what it takes to be a developer.  It can be very difficult to know where to start, how much progress you've made, and the logical next step and this list should assist with that as well as letting you know "how much is enough". 

This list is mainly focused on C# and hits on what topics you should learn for SQL, HTML, CSS, and JavaScript but the details of those are less fleshed out and you should seek out courses online (I listed at those areas to do so).

I believe that if you can learn 60-70% of this list well you could land a C# web developer job. I made the list more comprehensive because leaving off a random 30-40% doesn't make sense to me and some topics are more/less important to certain types of jobs depending on their technology stack.

How I made the syllabus: I broke down C# into Basics Part 1 and Part 2.  Part 1 is basic syntax and everything before classes.  Part 2 is utilizing classes, object oriented programming, and more intermediate C#.  Afterwards I think its good to learn APIs and back-end projects.  Logically next is SQL, databases, and ORMs.  Then front-end technologies.

In the future, I will have a GitHub codebase with projects that go along with this list and in the order of the list, but that is currently in progress and about halfway done. If you would like to follow along, my code is posted here: https://github.com/catenn/LearnCSharp


C# Basics Part 1

Git skills
  • Cloning down a new repository using Git Bash
  • Differences between Git Pull, Git Fetch, and Git Push and being able to run these commands in Git Bash
Visual Studio Skills
  • Using the Solution Explorer
  • Creating a brand new solution/project
  • Opening an existing solution/project
  • Using Git in Team Explorer
  • Understanding what the Git Sync button does
  • Handling merge conflicts
  • Creating a new class file easily
  • Adding new projects to an existing solution
  • Debugging code
  • Be comfortable using Intellisense
  • Be comfortable reading Intellisense notes and method signatures
Visual Studio Basic shortcuts:
  • Ctrl + X to delete a line
  • F5 to run a project
  • F10 to step over to the next line
  • F11 to step into a method
  • Highlighting a selection of code and dragging it to another location
  • Shift + Alt + F to fix formatting
  • Ctrl + R + R to rename a variable
  • Alt-selecting the same thing in multiple rows
  • Ctrl + Z to undo (and you can keep hitting this to keep undoing).  Ctrl + Y to redo something you undid (as long as you didn't type more)
C# Types, variables + initialization
  • Understand numbers: int, decimal, double, long, ulong, short, uint, byte, etc..
  • Understand booleans, boolean logic, using operators like '&&' and '||'
  • Understand char
  • Understand strings, string interpolation, and string concatenation
  • Understand char vs string and single vs double quotes
  • Understand what the term "immutable" means and how that relates to a string type
  • Learn what a StringBuilder is
  • Learn when to use string vs. StringBuilder
  • Understand what the keyword "new" does and when to use it
  • Define the difference between a reference type and value type
  • Understand what 'var' is
  • Understand variable initialization
  • Understand the scope of a variable based on whether the variable is in a class, method, loop, etc (not talking about access modifiers yet, just understand if a variable is in a class its available anywhere in the class, if its in a method you can use it anywhere in that method after its declared, if its declared in a loop you can only use it there, you may want to initialize something outside of a loop to use in a loop + use it after..).
  • Understand when to make local variables and when they are redundant. Understand that you can assign a local variable with the return value of a method. Example var a = TestMethod();
 C# Methods and parameters
  • Understand all parts of a method signature
  • Understand what a return type is
  • Know what it means to return void
  • Understand what static is and when to use it
  • Understand the difference between arguments and parameters.  You can push an argument into a method as a parameter.
  • Understand that when you push a variable into a method, that when the method receives it, it does not have to be called the same name on the other side.  However, naming convention wise it is common to call it the same name. 
  • Be able to set a local variable equal to the return value of a method. For example: int result = Add(1 , 2);
if/else and case/switch logic
  • Understand if/else if/else logic
  • Understand case/switch logic
  • Understand inverting if statement, and not having redundant/extra statement
  • Understand "!" syntax for "not"
  • Understand shorthand syntaxes
Collections: Lists, arrays
  • Understand arrays and how they work with types and capacity
  • Be comfortable working with lists
  • Be comfortable working with a list of lists
  • Understand how indexes work with arrays and lists + that they are zero indexed
  • Understand when to use an array vs. list and the benefits of each
Loops: for, while, foreach, do
  • For loops
  • While loops
  • Foreach loops
  • Do while loops
Basic utility/extension methods
  • ToString()
  • ToCharArray()
  • Trim()
  • ToUpper() and ToLower()
  • Substring()
  • Split()
  • ToList() 
Refactoring code practice

C# Basics Part 2

Basics of Classes, properties, methods in classes
  • Understand what a class is
  • Understand how to use and access properties under a class
  • Understand basic {get;set;}
  • Understand how to customize {get;set;}
  • Basic Inheritance between classes
  • Enums
Intermediate C#, Nulls, Regex, and Casting
  • Basic uses of LINQ
  • Regex
  • Dealing with null and checking for null
  • Understand what a nullable type is
  • Understand how to make something that isn't normally nullable into nullable
  • Using Dictionaries (collection type)
  • Tuples
  • Casting
  • Boxing
  • Unboxing
  • Implicit vs explicit cast
Separating large projects into multiple classes, namespaces, access modifiers
  • Understand what a namespace is and how to use them
  • Understand what an access modifier is
  • Public
  • Private
  • Internal
  • Protected
  • Protected Internal
  • Private protected
  • Sealed
  • Understand what the default access modifier is if one isn't listed
  • Understand read-only and const
  • Understand how access modifiers are related to namespaces
  • Understand how access modifiers affect Intellisense
  • Understand when/how to use each access modifiers
Class constructors
  • What is a constructor?
  • What does a constructor do?
  • Know that there are different type of constructors available and be able to define them: default, parameterized, copy, static, private
  • Class inheritance, interfaces .. Object oriented programming
More complex inheritance between multiple classes / multiple levels of inheritance and base classes
  • Interfaces
  • Abstract classes
  • Interfaces vs. abstract classes
  • Inheritance of abstract classes and interfaces
  • Overriding inherited methods
  • Method overloading
  • Method overriding
  • Understand what an extension method is, for example the LINQ methods
  • Optional parameters
Be able to define the 4 principles of OOP
  • Encapsulation
  • Inheritance
  • Abstracton
  • Polymorphism
Design Patterns
  • Be able to define SOLID
  • Understand that Gang of Four exists / what that is
Unit testing
  • Naming convention for project, class files, and method names
  • AAA - Arrange, Act, Assert
  • Writing a basic unit test for a method
  • Writing unit tests to cover a class
  • Test attributes
  • Running unit tests
  • Debugging unit tests
  • Code coverage
  • Test Driven Development (TDD) and red/green/blue
  • What is mocking?
  • What is Moq?
  • Know there are different frameworks like Nunit, Xunit, and MSTest.
Debugging practice, fix broken code!


Creating a backend API App:

  • APIs - what are they, how are they used, etc.
  • Get
  • Put
  • Post
  • Patch
  • Delete
  • How an API project can be accessed by a front end
  • How an API project can reach into other layers of logic and get data to a database
  • How dev teams can be split into back-end and front end and work out of sync + where the split is in work
  • How an API project can be published to Azure and be a live site
  • Basic error codes, 404, 500, 200, etc.
API Tools:
  • Swagger - know how to use this to test out APIs with the localhost/swagger URL
  • Postman - know how to use this to test out APIs
  • Fiddler - install this tool, understand how it works
Learn what dependency injection is
  • Basic dependency injection and what it is
  • Names of frameworks like Unity, Castle Windsor, Autofaq
Debugging practice with tools and full back-end solution

SQL -

  • What is a database? What is SQL?  
  • Go through: https://sqlzoo.net/ 
  • What is a database?
  • What is SQL?
  • What is NoSQL
  • SQL vs NoSQL
  • Learn what MongoDB, CosmosDB, Cassandra are and be able to define them only
  • Understand basic table structures and how data is broken up into different tables
  • Be able to query easily (CRUD operations) SELECT, INSERT, UPDATE, DELETE, etc.
  • T-SQL
  • Stored Procedures
  • Joins
  • Keys
  • Foreign Keys
  • Triggers
  • Know what ACID is
SQL Server Management Studio (SSMS) basics
  • Be able to login to a local SQL Server
  • Be able to login to an Azure SQL Server
  • Be able to find databases, tables easily
  • Be able to edit tables manually in SSMS
  • Feel comfortable using SSMS as a tool
  • Understand difference between SSMS and the DB itself
  • Understand the difference between local vs. Azure IaaS vs. Azure PaaS SQL
  • How to connect web app to SQL, ORMs
What is an ORM?
  • What does an ORM do?
  • ADO.NET
  • Dapper - learn what this is and what is can do
  • Entity Framework - learn what this is and what is can do

Javascript -

  • Basic JavaScript syntax and logic
  • Take online course on JS like CodeSchool.com or CodeAcademy.com
  • Know what jQuery is and what it is for
  • Know what AJAX is and what it is for
  • Know what React JS and Angular JS are and very basics of these / compare and contrast these two frameworks
  • Know what Vue.JS is
  • Browser debugger
  • Be comfortable using the debuggers in each browser: Chrome, Firefox, and Edge

HTML/CSS

  • Take a HTML and CSS online course
  • Know how to make a basic HTML5 page with divs or tables
  • Know all basic HTML elements
  • New HTML5 elements
  • Good practices with CSS and how to use periods and spaces to chain CSS
  • When to and not to use "important" css styling with "!"
  • Twitter Bootstrap framework and use of it
  • SASS
  • Know what bundling is

End to End - Debugging

  • Reading and understanding stacktraces
  • How to use try/catch, setup exceptions
  • Exceptions
  • Error checking
  • Throw/Catch errors
  • How to determine if bug is in front end, backend, or DB issue. Be able to explain this on an interview.

Agile/Scrum/Devops Basics

  • Understand how requirements can be broken into Epics/Features/User Stories
  • Understand what a User Story / Product Backlog Item is
  • Be able to read a business requirement and break it into technical steps that you can estimate in hours.
  • Understand how to estimate your work in hours (always over-estimate!)
  • Know what Agile is
  • Know what a Kanban workflow is
  • Know what a Sprint is.. understand sprint planning, stand-up, sprint review, sprint retrospective meetings and their purposes
  • Understand what the following roles do: Product Owner, Business Analyst, Scrum Master, Quality Assurance, and how you work with these roles at work. 

Advanced topics / Optional / Nice to know topics

  • Understand what the cloud is and what Azure, AWS, and Google Cloud are.  Understand the difference between cloud and on-premise offerings.  Understand the terms SaaS, IaaS, and PaaS in relation to cloud services. 
  • UML Diagrams
  • Recursive functions / recursion
  • C# Dynamics
  • Binary operators
  • Knowing binary
  • Compile time vs Runtime
  • Structs
  • Delegates
  • DevOps CI/CD
  • Git Branching, switch branches, branching strategies, overall release strategy
  • Angular / React JS
  • Design Patterns/Architecture
  • Stack/Heap
  • Runtime, JIT, etc
  • Pointers
  • Basic Networking

Sunday, April 28, 2019

Algorithms: Union-Find in C#

Union-Find Algorithm: Imagine if you have 100 computers in a room not networked to one another. You could use a Union(computer1, computer2) method to join 2 computers together in a network. From there, you could continue joining computers together randomly and you would want to have a method that returns a bool called Connected(computer1, computer2) that determines if they are already connected, so you don't have to do the work if they're already in the same network.
    /// 
    /// Initialize: N
    /// Union: N
    /// Find: 1
    /// Accesses: takes N^2 accesses to process sequence of N union commands on N objects
    /// Summary: Union is too expensive. Too slow for huge problems. Quick union will be a little faster. 
    /// 
    public class QuickFindUF
    {
        private int[] id;

        public QuickFindUF(int N)
        {
            id = new int[N];
            for (int i = 0; i < N; i++) id[i] = i;
        }

        public bool Connected(int p, int q) // Find
        {
            return id[p] == id[q];
        }

        public void Union(int p, int q)
        {
            int pid = id[p];
            int qid = id[q];

            for (int i = 0; i < id.Length; i++)
            {
                if (id[i] == pid) id[i] = qid;
            }
        }
    }
Now, if we wanted to be a little more efficient, we could setup the connections to be in a tree format. Each computer will reference it's parent's number as an ID. The root computers will reference themselves as their ID, so you can check for that to tell if a computer is a root of a tree.
    /// 
    /// Faster than QuickFindUF, but still too slow.
    /// Too expensive because trees can get too tall or too flat (extremes).
    /// 
    public class QuickUnionUF
    {
        private int[] id;

        public QuickUnionUF(int N)
        {
            id = new int[N];
            for (int i = 0; i < N; i++) id[i] = i;
        }

        private int Root(int i)
        {
            // Chase parent ID until reach the root (depth of i array accesses)
            while (i != id[i]) i = id[i];
            return i;
        }

        public bool Connected(int p, int q) // Find
        {
            return Root(p) == Root(q);
        }

        public void Union(int p, int q)
        {
            int i = Root(p);
            int j = Root(q);
            id[i] = j;
        }
    }
Lastly, we could have balanced trees to ensure we have no extremely tall trees. A component is how many groups of computers that we have a component could be 1 computer by itself, or it could be all of the computers in a component if every computer has been networked together at some point with the Union() method. We should keep track of the size of each component and how many total components we have in our data set.
/// 
    /// Keep track of tree size and take steps to avoid having tall trees.
    /// Smaller tree will connect to the root of the larger tree.
    /// Java implementation on p. 228
    /// Depth of any node x is at most lg N (lg = base-2 logarithms)
    /// If N is 1,000 its 10 (2^10 = 1000)
    /// If N is 1,000,000 its 20 (2^20)
    /// If N is 1,000,000,000 its 30 (2^30)
    /// Can also add path compression: just after computing root of p, 
    /// set the id of each examined node to point to that root
    /// 
    public class QuickUnionUF2 // Weighted Quick Union
    {
        private int[] id;
        private int[] sz;
        private int count; // number of components

        public QuickUnionUF2(int N)
        {
            id = new int[N];
            for (int i = 0; i < N; i++) id[i] = i;

            sz = new int[N];
            for (int i = 0; i < N; i++) sz[i] = 1;
        }

        public int Count() { return count;  }

        private int Root(int i)
        {
            // Chase parent ID until reach the root (depth of i array accesses)
            while (i != id[i])
            {
                // Halves path length. No reason not to, keeps tree almost completely flat.
                id[i] = id[id[i]]; // Only 1 extra line of code to do path compression improvement! 
                
                i = id[i];
            }
            return i;
        }

        public bool Connected(int p, int q) // Find
        {
            return Root(p) == Root(q);
        }

        public void Union(int p, int q)
        {
            int i = Root(p);
            int j = Root(q);

            if (i == j) return;

            // Make smaller root point to the larger root.
            if (sz[i] < sz[j]) // if i is smaller than j
            {
                id[i] = j; // point i to new root j
                sz[j] += sz[i]; // add the count of the smaller array to the count of the larger array
            }
            else // if j is smaller than i
            {
                id[j] = i;
                sz[i] += sz[j];
            }

            count--; // if we combine components, the count of components goes down by 1
        }
    }

Monday, March 4, 2019

Side Gigs while Transitioning Careers (or in general)

I've gotten this question a lot lately, so decided to just make a post about it: "What are side gigs I can do to earn money while transitioning careers?" I will list out all the ideas I can think of here and more details for the ones I know about.

Why do I know about these? I needed some of these when I switched from medicine to software and did some on the side on night/weekends.  I have friends with flexible work. I traveled a lot for work and talked to people around me. Sometimes I was on the customer side. And, reading PennyHoarder for kicks.

The list below will be mostly applicable to US residents. Some of this is available in other countries/regions, but I live in the US and can provide a list that is useful for where I live. If you are a good writer, don't mind driving, or are bilingual, you will have lots of options!

Remote:
Google Ads Rater - look at google search queries and see if the results are good, see if ads graphics are related to the text topic, see if queries for videos bring back a good result video, etc. To do this, basically apply for a spot within one of the below companies, wait for them to select you, you start taking exams from them based on material they send you (usually a large-ish PDF manual), pass tests, start doing work.  It can be a bit brain numbing but easy money around $13/hour that you can do while watching Netflix. It's not very intensive or hard as long as you are good at absorbing the rating requirements that were taught in the training manuals. Note historically there were 4 companies when I did this 5 years ago, it looks like in 2019 it is down to 2.
    • LionBridge - Current Job Openings (click on testers, raters, and curators for Google Ads rater jobs, if you are bilingual you can investigate the translator or interpreter options).
    • Appen Butler - Current Job Openings (click raters for google ads, or if interested checkout language jobs or micro tasks).
    • Leapforce has been acquired by Appen.
    • ZeroChaos <-- I believe was dropped from Google in 2017 due to this article.
VIPKID Teachers - teaching English via online conference call to children in China. Need to be very enthusiastic and require a Bachelor's degree in any field and to be in the US or Canada.
Amazon Turk - basically random tasks people need a person, not a robot to do. It could be literally anything manual, reading/writing/recording audio, analyzing, testing things out, checking grammar, translating, making subtitles, you name it. You can screw up and make like $1 an hour picking low paying tasks, or as much as $20ish an hour. I believe most folk average around $10 an hour. Do your research based on the links below and do your own research before embarking on this one so you know how to earn a decent hourly wage.
iTalki - If you can speak a foreign language and want to teach the foreign language, or teach English to those who know the same foreign language as you, this is a top notch website.  I used this site as a learner to learn a foreign language and its a reliable and well put-together process.  You sign up as a tutor, put up your schedule, and people sign up for lessons with you.  You do lessons via Skype video typically, unless you and the student agree on a different video conferencing program.  You can teach in any way you choose, come up with your own materials and plan based on the student.
  • Freelance Writing - I don't know much about this area but just giving this as an idea.
  • Translator - I don't know much about this area but just giving this as an idea.
Local In-Person Flexible Jobs:

  • Bartending - find a local bartending job at a hotel or restaurant.  The more expensive the joint, the better the tips will be.
  • Mystery Shopping -  You get paid to pretend to be a shopper and make sure employees are doing what they are supposed to (coffee at the right temperature, introductions, talk about some sales/rewards program, checking IDs for alcohol, etc.). Typically you get reimbursed for whatever item you buy and a payment for your time for doing the task and writing up a report.  You need to have decent grammar/writing/spelling skills and do a good job on the report.  If you mess up the report, you won't get paid or reimbursed, so be careful, but most people who are very meticulous will have no issues with this. Typically you pay for items with your credit card and are reimbursed, so you need a credit card and have to be ok with a reimbursement coming 7-90 days later.
  • Pet Sitting - you either visit/stay at someone else's place or take in their pet to your home.  There are websites that are local to your area and more national reach ones, search for pet sitter on google and you can checkout options for your area.
    • Rover - large customer/sitter base nationwide
  • Dog Walker - walk dogs! Google this and find out what you have locally, etc.
    • Rover - large customer/sitter base nationwide
  • Focus Groups - Usually target some specific demographic, if you are in it, apply! Mostly one and done, you apply, if you get in, you do some task, easy money, and they pay you right after.
  • Tutoring - tutor adults and kids in some topic! Could be elementary school math, SAT, MCAT, languages, anything! Do some research online for other options, the one I used was below:
  • Research Studies / Medical Research Trials - just an idea

Local In-Person Flexible Jobs Related to Driving and Food:

  • Uber - rideshare option, drive folk around on your own schedule. Most people join both Uber and Lyft to make sure they get rides from both. There are a lot of strategies to get the most rides, rush hour, weekend nights, and hovering around the airport are all good ideas.  You do often wait in a queue if you are in an airport or busy location like that.  Stick to downtown areas for weekend nights if you want the bar scene, also wrap up your car with plastic wrap in the back and provide doggy bags in case of sick folk who drank too much if you do this. 
  • InstaCart - food delivery or in-store shopper, sometimes the same person does both, but usually these are two separate jobs.
  • PrimeNow Shopper - work in Whole Foods and assemble orders
  • UberEats - food delivery
  • DoorDash - food delivery
  • GrubHub - food delivery
  • BiteSquad - food delivery
  • Postmates - food delivery
One last note, a pretty good website to come through for more ideas is The Penny Hoarder.

Thursday, January 17, 2019

How to Become a Business Analyst

Image result for business analyst

I created some training material for the IIBA (International Institute of Business Analysis) local Tampa chapter and it is open for anyone to utilize.  I have am working with them to help with training in using Azure DevOps (formerly VSTS/TFS) and for new folk to the field.

How to get into the field:
  • I would recommend getting the Scrum.org and the ECBA certification from the IIBA.  The best way to go for the ECBA certification is to pay for the membership for the IIBA which will give you lots of training materials and an exam discount (about the price of the membership so it's like free materials!).
  • Go to local meetups and search for IIBA in your area and find some nice folk to ask about the field and what the job is like!
  • When searching for jobs make sure to search for a generic "Analyst" as there are many, many names for Business Analysts.  Also add in keywords for "entry level" or "junior" and don't be afraid of the requirements or years of experience they ask for in the posting, that is simply a wish list of an ideal candidate, not a real person that they actually plan on finding (especially for junior roles). 
  • Write a cover letter explaining why you are interested in the Business Analyst role, why you are a good fit, what you have done to prepare yourself, what skills you have, and why you are interested in the particular company you are applying for.
  • On the top of your resume, list skills that are relevant to the IT field and the Business Analyst role.  Members of local meetups or industry Analysts can help you out!
  • Learn about Agile, Scrum, SDLC, Epics/Features/User Stories, and more by searching online.  Also... see below on this point:
I have some training on how to write Epics/Features/User Stories and examples of how to break things down.  I also have hands on labs on how to utilize Azure DevOps as a tool in the Business Analyst role.  Azure DevOps is completely free to use for up to 5 people (so for 1 person learning, it's a great tool). The labs and info is all free and I just hope it helps someone out!

Please click here to see it: https://github.com/catenn/IIBA/wiki

Note: I am not a Business Analyst, I am a developer who has partnered up with Business Analysts to make this training. I do work at Microsoft and I do train Business Analysts on how to utilize Azure DevOps as a tool, but I do not train Business Analysts on how to do their role.

Tuesday, January 15, 2019

Networking Part VI: Azure Networking - VMs, IP Addresses, and Load Balancing

This is part 6 of a series of networking posts:
Azure VM Networking
  • A NIC on a VM can connect to your VNet for example. Properties of a NIC that are normally set in the OS are able to be configured in Azure for your Azure VMs.  
    • Note: VMs (and all other resources) need to be deployed to the same region as your VNet.  So you need a VNet for each region that you have resources.
  • A NIC on a VM can also be attached to a load balancer (for highly available applications). 
  • Up to 250 IPs can be assigned per NIC, and these can be public or private IP addresses.  
    • You can add/edit IPs by going to your VM resource > Network interface > Settings > IP Configurations > Add.  If you select an existing IP address, you can go into another menu where you are able to enable it as Public/Private or assign it as Dynamic/Static. You can also change the actual IP address value for Static IPs.   Changing to a new IP address will cause the VM to reboot.
  • You can add more NICs to the VM if you need more IPs from a Microsoft block of reserved IP addresses (you cannot port in your own IP address ranges that you are using on prem or otherwise).
  • The underlying Azure platform handles connections to/from the machine, you should not RDP into your VM and setup a static IP address for you IPv4 (you will lose access to your machine, it is an unsupported action for an Azure VM and well documented). 
  • You also should not install a DHCP service on your VM (unsupported as well). You can do dynamic or static IP addresses for your VM.
    • Dynamic Host Configuration Protocol (DHCP) is a client/server protocol that automatically provides an Internet Protocol (IP) host with its IP address and other related configuration information such as the subnet mask and default gateway.
  • MAC address persistence: by default we guarantee that the MAC address will not change for a VM or NIC provided the VM is not deleted, redeployed from disks, or redeployed using the redeploy feature that rebuilds the virtual hardware.
  • When you create a new VM you can add it to an existing VNet and subnet.  If you want it publicly available, you can add Public IP, or if you don't then select None for the Public IP address (and it will automatically get assigned only a private IP address).  You should create a new NSG for it (default option).

IP addresses
  • IP addresses are treated as a separate resource in Azure, which allows you to move it from one resource to another.
  • Not all resources in Azure support a static (reserved) IP. For example, a VPN Gateway or Application Gateway do not support a static address because they are Microsoft managed resources. The dynamic IP will not change unless you delete or redeploy that resource, however. 
  • Static (reserved) Public IPs - retain the IP address.  The IPs can be moved between services easily and within seconds. 
  • Public IPv4 resources are a finite resource. You can have 5 public static IP addresses as part of your Azure subscription for no cost, but any additional ones will start becoming a billable resource. Dynamic IPs can help you with cost savings as they are cheaper than static IPs.
Load Balancing
Azure has 4 different options for traffic distribution:

1. Traffic Manager - DNS based
An illustration showing Azure Traffic Manager routing a user request to the nearest data center.

2. Azure Load Balancer - Layer 4 of OSI model (TCP/UDP)
An illustration showing the web tier of a three-tier architecture. The web tier has multiple virtual machines to service user requests. There is a load balancer that distributes user requests among the virtual machines.

3. Application Gateway - Layer 7 of OSI model (HTTP/HTTPS), can start to add in some Web Application Firewall (WAF), SSL Termination and Cookie based affinity
4. 3rd Party Virtual Appliances - Layer 3-7 of OSI model.  Network Virtual Appliances (NVAs) are simply custom IaaS VMs that can provide network functions such as firewall, app firewalls, IDS/IPS, load balancer, and VPN terminators. Azures IP forwarding and UDRs can help send packets to these VMs or override default routing behavior.  Many NVAs are available in the Azure Marketplace. Some common vendors are:

  • Cisco
  • Citrix
  • F5
  • Infoblox
  • Check Pint
  • Fortinet