Saturday, August 17, 2019

Common Azure Database Migration Issues

Data Migration Assistant helps to assess your on-premise database readiness to migrate to Azure. DMA identifies the compatibility issues and provides the recommendation on alternatives.

Unsupported features:

  1. Windows Authentication is not supported on Azure SQL database
  2. Service Broker feature is not supported Azure SQL database


Compatibility issues:
  1. Deprecated datatypes (TEXT, IMAGE, NTEXT). Alternative varchar(max), nvarchar(max), varbinary(max) 
  2. Table hints in indexed view definitions are ignored in compatibility mode


Sunday, August 11, 2019

Assessing and planning Microsoft Azure Migration

Many of the organizations are planning to migrate workload/applications to cloud.

Fist step is to access the azure readiness of the workload. There are set of tools available for assessment. How do we start?

  1. Azure Migrate
  2. Service Map
  3. Site Recovery

Azure Migrate helps to assess the VMWare VMs in the data center. Currently it doesn't support physical servers.


Site Recovery helps to migrate VMs and physical servers to cloud.

Vertical and Horizontal Scaling

Vertical scaling is known as Scale up.
It is a process of adding resource to increase power of an existing server
Example: Adding CPU or Memory

Horizontal scaling is known as Scale Out.
It is a process of adding more servers.
Example: More than one server will be processing the input request from user

Benefits of moving to cloud

Few of the advantage of using cloud are

  • Cost-Effective: Pay-as-you-go - It is consumption based model. 
  • Scalable: Support both vertical & horizontal scaling
  • Elastic: It is easy to scale in & scale out depending on business need.
  • Reliable: data backup, disaster recovery and data replication
  • Reduced IT workforce - Cloud provider is responsible for maintaining physical hardware.

Sunday, March 24, 2019

Moq Sample:

Class to be unit tested:

public class A
{
    B _objectB;
    C _objectC;

    public A(B objectB, C objectC)
    {
        _objectB = objectB;
        _objectC = objectC;
    }
    public virtual int Operation(int number1, int number2)
    {
        int result = 0;

        result += _objectB.Multiply(number1, number2);
        result += _objectC.Divide(number1, number2);

        return result;
    }
}

Unit testing with mocking:

using Moq;
using Xunit;

public class ATest
{
    [Fact]
    public void Operation_MockDependencies_ShouldPass()
    {
        //Arrange
        Mock mockB = new Mock();
        Mock mockC = new Mock();
        var sut = new A(mockB.Object, mockC.Object);
        int number1 = 10;
        int number2 = 5;

        mockB.Setup(x => x.Multiply(number1, number2)).Returns(10);
        mockC.Setup(x => x.Divide(number1, number2)).Returns(25);

        //Act
        var result = sut.Operation(number1, number2);

        //Assert
        Assert.Equal(35, result);
    }
}

What is Moq


  • Moq is a mocking framework for .NET
  • Pronounce as “Mock-you” or “Mock”
  • It helps to isolate dependencies in unit testing
  • Nuget packages
  • Moq (4.10.1)
  • Reference: https://github.com/moq/moq4


xUnit sample

Class to be unit tested:

public class A
{
    B _objectB;
    C _objectC;

    public A(B objectB, C objectC)
    {
        _objectB = objectB;
        _objectC = objectC;
    }
    public virtual int Operation(int number1, int number2)
    {
        int result = 0;

        result += _objectB.Multiply(number1, number2);
        result += _objectC.Divide(number1, number2);

        return result;
    }
}

Unit test:

using Xunit;
public class ATest
{
    [Fact]
    public void Operation_WithCorrectParameters_ShouldPass()
    {
        //Arrange
        int number1 = 10;
        int number2 = 5;
        var sut = new A(new B(), new C());

        //Act
        var result = sut.Operation(number1, number2);

        //Assert
        Assert.Equal(52, result);
    }

}

What is xUnit


  • xUnit is unit testing tool for .NET framework
  • It is free & Open Source (Licensed under Apache)
  • Supports .NET core
  • Nuget packages
  • xunit (2.4.1)
  • Xunit.runner.visualstudio (2.4.1)
  • Reference: https://xunit.github.io/