Monday, June 15, 2020

Azure - Availability Set

Availability Sets is designed to provide high availability of your application in terms of ensuring the protection of your application from power failure, network failure, downtime due to software patch updates.

You need to have multiple VMs like Web vm1/ Web vm2..., App vm1/ App vm2...., DB vm1/DBvm2.....

If you want to leverage 99.95% SLA from Microsoft you must place your VMs inside availability set. Your VMs must use Microsoft managed storage(premium storage).

Fault Domain: VMs in a fault domain share the same rack, network, power supply. It means when a fault domain fails all VMs inside that fault domain go down.
So the Availability Set arranges Web vm1 in FD0, Web vm2 in FD1, and so on.
Availability Set by default has 3 Fault Domains

Update Domain: It is a logical unit. All VMs that reside in an Update Domain get software updates, patch updates, reboot altogether.
So the Availability Set arranges Web vm1 in UD0, Web vm2 in UD1, and so on.
Availability Set by default has 5 Update Domains

The sequence could be any but at a time only one Update Domain gets updated and rebooted, with given 30 min downtime. 





Assignment of FD and UD to VMs takes place as given below

Virtual Machines
Fault Domain (3 Fault doamins)
Update Domain (5 Update domains)
VM 1
0
0
VM 2
1
1
VM 3
2
2
VM 4
0
3
VM 5
1
4


MS Reference https://docs.microsoft.com/en-us/azure/virtual-machines/windows/tutorial-availability-sets

Monday, April 20, 2020

AZR - Shared Access Signature

A shared access signature (SAS) provides secure delegated access to resources in your storage account without compromising the security of your data. With a SAS, you have granular control over how a client can access your data. You can control what resources the client may access, what permissions they have on those resources, and how long the SAS is valid.

When a client proxy or user needs direct access, you can provide customized access.

Customize which specific access you want to give to any user or client


Generate SAS and share with client to access 


Sunday, April 12, 2020

AZ - IP Address

IP Address format X.Y.Z.M



X
Y
M
N

Max value
255
255
255
255

Min value
0
0
0
0

Memory Size (bit)
8
8
8
8
32 bit
Memory value ex.
11101011
11001001
10001011
11101001
32 bit


IP Address
X
Y
M
N
Network Part Digits
Sample 1
10.10.1.0/8
10
10
1
0
/
8
Sample 2
10.10.1.0/16
10
10
1
0
/
16
(8+8)
Sample 3
10.10.1.0/24
10
10
1
0
/
24
(8+8+8)


Network Part
Wide Network Address
Host Part
Machine's locality address


Friday, April 5, 2019

AWS - Beanstalk

AWS Elastic Beanstalk is an service for deploying and scaling web applications and services developed using Java, .NET, PHP, Node.js, Python, Ruby, Go, and Docker on servers like Apache, Nginx, Passenger, and IIS.
We can simply upload our code and Elastic Beanstalk automatically handles the deployment, from capacity provisioning, load balancing, auto scaling to application health monitoring. At the same time, you retain full control over the AWS resources powering your application and can access the underlying resources at any time.
There is no additional charge for Elastic Beanstalk - you pay only for the AWS resources needed to store and run your applications.

















CLI Command to deploy .net web app using Elastic beanstalk

Key steps: 

  1. Publish your app using:

    dotnet publish -c Release
  2. Zip the output folder.

  3. Deploy to Elastic Beanstalk via AWS Management Console or CLI:

    aws elasticbeanstalk create-application-version --application-name MyApp --version-label v1 --source-bundle S3Bucket=mybucket,S3Key=myapp.zip


Benefits 
  1. Fast & Simple: Its very useful for those not having deployment and infrastructure knowledge.
    You simply use the AWS Management Console, a Git repository, or an integrated development environment (IDE) such as Eclipse or Visual Studio to upload your application, and Elastic Beanstalk automatically handles the deployment details of capacity provisioning, load balancing, auto-scaling, and application health monitoring. Within minutes
  2. Productive for Developers: No need to spend time to learn deployment techniques 
  3. Auto Scaling: It provides auto scaling. Scale up to handle high load and traffic and scale down for cost saving automatically using your config settings.   
  4. Resource Control: Full control to select your choice resource like EC2 instance ex. t2.micro
    You have full control over underlying resources opted through beanstalk, you can takeover on some/all resources you want. It keeps resources up to date with latest updates/patches
Points to Remember:
  1. You can have multiple versions of your application 
  2. Your application can be split in multiple tiers like web tier, app tier and database tier 
  3. You can update application whenever needed 
  4. You can update configuration whenever needed 
  5. update can be 1 instance at a time, % wise update or immutable update (creating separate copy) 
  6. Beanstalk is free, you pay for resources opted 
  7. Beanstalk can create database for you but it get deleted if you delete beanstalk.So better create your separate database and link with beanstalk, with this approach database would not deleted with Beanstalk 
  8. Supported languages and servers for them
    1. Apache Tomcat for Java Applications 
    2. Apache Http server for PHP applications 
    3. Apache Http server for Node JS applications 
    4. Nginx or Apache Http server for python applications 
    5. Java SE 
    6. Docker 
    7. GO 
    8. IIS 7.5, 8.0 8.5 for .Net applications 
    9. Passenger or Puma for Ruby
  9. Configuration applied while creation or updation of environment from multiple sources as given 
    1. Settings applied directly to the environment: Direct setting applied from sources like AWS management console, EB CLI, AWS CLI or SDK, AWS and EB CLI also apply recommended values. 
    2. Saved Configuration: Settings for any option that are not applied directly to the environment are loaded from Saved Configuration. 
    3. Configuration Files: (.ebextensions) Settings for any option that are not applied directly to the environment and from Saved configuration are loaded from Configuration files, multiple .ebeextensions files executed in alphabetic order from folder .ebextensions root of the the application. 
    4. Default Values: If any configuration option has default value and it has not been supplied any value from options given above then default value will be applied.
  10. Immutable deployments perform an Immutable Update to launch a full set of new instances running the new version of the application in a separate Auto Scaling group, alongside the instances running the old version. Immutable deployments can prevent issues caused by partially completed rolling deployments. If the new instances don't pass health checks, Elastic Beanstalk terminates them, leaving the original instances untouched.






Saturday, December 1, 2018

.Net Core | Using Libraries & Packages

  • Server-side Libraries
    Nuget is the source for all kind of server side libraries and packages.
  • Client-side Libraries
    For client side libraries like js and css, its recommended to refer them directly from CDN, to leverage their fast loading. If want to use them locally than these can be downloaded from Node Package Manager (NPM).
    You can download client side tools from NPM or command line or MS package installer.
How to use NPM (Node Package Manager)
  1. Add new npm Package Configuration file.


  2. Add whatever packages you want to add in devDependencies. 
  3. Hundreds of useful client side packages available in NPM like Jquery and bootstrap.

  4. When you add libraries in NPM configuration file (package.json), visual studio automatically installs them.


  5. Its install in hidden node_modules folder, and in lib folder in wwwroot. 
  6. you can than copy/keep only required minified versions of libraries in www folder.

Saturday, October 27, 2018

.Net Core | Http Request Pipeline & Middleware

In .Net Core web application initialization and startup has been totally changed.

Configure Method of Startup class configures Http Request pipeline.

  • Global.asax has been removed. 
  • ini, xml and json files taken place to use in configuration 


Middleware

Middleware is software that's assembled into an app pipeline to handle requests and responses.
  • A Middleware can choose whether the request has to pass to next component or it can terminate the chain that is called Short-Circuiting the pipeline. Middleware3 is doing it in below example.
  • Middleware can perform work before calling next component and can perform work after the next component call finishes.




Run, Map and Use methods 


Run: First occurrence of Run terminates the executor branch or request pipeline if no branches. 



public class Startup
{
        public void Configure(IApplicationBuilder app)
        {
            app.Run(async context =>
            {
                await context.Response.WriteAsync("Hello megabyteland.blogspot.com");
            });
        }
}

Use: To configure multiple middlewares you need to use Use method. Second parameter of Use is delegate for next middleware defined in the pipeline.
public class Startup
{
  public void Configure(IApplicationBuilder app)
        {
            app.Use(async (context, next) =>
            {
                // Do work before invoking next middleware.
                await next.Invoke();
                // Do work after invoking next middleware.
            });

            app.Run(async context =>
            {
                await context.Response.WriteAsync(("Hello megabyteland.blogspot.com");
            });
        }
}


CI/CD - Safe DB Changes/Migrations

Safe DB Migrations means updating your database schema without breaking the running application and without downtime . In real systems (A...