Sunday, May 16, 2021

File recovery from VM backup(Recovery Service vault)

Backup service can be enabled on VM through recovery service vault. This will primarily facilitate restoration of a VM from Backup when disaster happens.  

Full VM restoration is  rare requirement ,how about recovering  files/folders incase the same is corrupted or accidentally deleted.  

File recovery capability of Recovery service vault can take care of this requirement.

1. Go to respective Vault

2. Select "Backup Items" from left panel 

3. Select the desire item from right side window.

4. From top menu click on "File Recovery" and follow the steps below




5. Click on the dropdown "Step 1: Select recovery point" and search for desire target date

6.  Save "Download Executable" locally and  run it, This will create a MAP drive

7.  Open windows explorer and browse through the map drive and copy the desire       
     files/folder to target VM

Once done , don't forgot to click "Unmount Disk"

Saturday, May 15, 2021

Remove a specific recovery point from Recovery service vault

No you can't do that.
This is not allowed either from Azure portal or from PowerShell and CLI.
I had a business requirement to move 8 years VM backup from Recovery Vault to Blob Storage.

It was completely a manual activity as Azure doesn't offer data migration from vault to storage.  We decided to remove restore point from vault as soon as we move the data to storage to reduce vault cost. 

This approach didn't stand since recovery service vault doesn't support deletion of restoration point. As an alternative we decided to modify BackUpPolicy and reduce retention period progressively in sync with data migration progress. Team who worked they started moving vault data from most old restoration pint to most recent point.

Azure VM - static private IP address

When  we create a Azure VM, it automatically assign a private IP address from the range define in subnet where VM is deployed.

This private IP will remain unchanged until VM is deallocated or decommissioned.

If Network configuration demands a fixed private IP assign to the VM which should work even after VM resumes from deallocation, then static private IP address would be the solution.

Static private IP address allows a specific hand picked IP address assign to the VM.

Static IP address is specially needed  when private DNS requires a A record entry.

Assign static IP address is easy:-

1. Select the VM from Azure portal

2. Go to "Networking" page and select "Network Interface"

3. Click on existing IP address from list

4. Now change the assignment to "Static" from "Dynamic"

5. In the text below specify the desire IP address and click on save.

Thursday, May 13, 2021

Vault cannot be deleted as there are existing resources within the vault


I spent almost half of a day to figure out this issue.  Exception was self explanatory but finding the solution was difficult.

You may experience this error when try to remove a Recovery service vault, Root cause is explained below.

This error signifies that Recovery vault has dependency on a storage account. To resolve this issue, you have to unregister storage account from vault.

Steps are very easy :-

1. Go to target recovery service vault 

2. Select "Backup Infrastructure" from left side panel

3. Select "Storage Accounts" from left side panel

4. From the right side panel , select the storage name and then click on "Unregister"

Now try to delete the vault again and see the magic.


Wednesday, May 12, 2021

Advantage of MFT over normal FTP

MFT  stand for Managed File Transfer and FTP stands for File Transfer Protocol. 

Both are use for transferring file from client computer to server computer.
However considering cybersecurity threats in mind  it is always advisable to use MFT.

Traditional FTP service transfer file over unsecure channel  whereas MFT support advanced security protocol and transfer file over a secure channel. It supports variety of protocols like.

1. FTPS
2. SFTP
3. AS2

Update VM size for old generation VM

Your workload is hosted on old generation or promo SKU, for such situation migrating to a new generation SKU is always difficult. We can't find the desire SKU from VM upgradation bled.

Following are the steps to accomplish this.

1. Deallocate the VM (Not stop , deallocate is different than stop)

2. Go to VM upgradation bled and select desire VM size and proceed.

Note: Desire VM size will not available until VM is deallocated.

Cons: Deallocation of VM will release dynamic IP(public and private), make sure your infrastructure doesn't depend on existing dynamic IP otherwise assign static IP to VM before resizing.

Take a full backup of VM for disaster , there might be a chance of unsuccessful upgradation.


Monday, May 10, 2021

Azure Constrained vCPU

Azure VM vCPU and RAM always proportionally increase from one SKU to immediate next SKU.

This method doesn't stand for vCPU based software license like database software e.g. SQL Server and Oracle.

Database software often demands more memory to add whereas vCPU will remain unchanged.

Azure constrained vCPU will address this issue. This will allow to add/remove more RAM on the same workload  whereas vCPU and other parameter will be same.

Monday, December 3, 2012

DbSet.Find() in Entity Framework


DbSet.Find method in Entity framework provides some cool and awesome features.
Unlike other it doesn’t except lambda expression whereas it accept only primary key(s) value.

var cat = dbContext.Categories.Find(1);

Above will retrieve the category where category id is 1. “categoryid” is defined as primary key in the underlying table. Incase composite primary key we should pass values in the same sequence of keys.

var data = dbContext.Products.Find(1, 10);

So far, behavior is simple but nothing special. Wait ….following features will make it incredible.

Find() will always not make a database trip to fetch the data rather it supports following principles.

     1.  Find the data in memory and returns it.

var
cat = dbContext.Categories.Find(1);
cat.Description = "Modified";
//Modified data in the memory will be returned
cat = dbContext.Categories.Find(1);

     2.  Look at the newly added data in memory.

var cats = new Category
{
  CategoryID = 1001, CategoryName = "New Category",
  Description = "New Category Description"
};
dbContext.Categories.Add(cats);
// newly added data in the memory will be returned
cats = dbContext.Categories.Find(1001);

3   3.  It makes a database trip only when 1 and 2 fails to return any data.

Wonderful isn’t it. I really liked it very much.

Thursday, November 29, 2012

LINQ and equivalent LAMDA expression


This discussion I will try to provide some common LINQ statement and the equivalent LAMDA expression. This is purely personal preference to choose LINQ or Lamda. I am not going to describe which one is the best way considering performance as parameter. What I noticed both emit the same IL code after compilation. I used Entity framework 5.0 and Northwind database for this sample.

Retrieve all records
LINQ
from c in dbContext.Categories
       select c;
LAMDA
dbContext.Categories.Select(c => c);

Specific fields
LINQ
from c in dbContext.Categories
       select new { c.CategoryName, c.CategoryID };
LAMDA
dbContext.Categories.Select(c => new { c.CategoryName, c.CategoryID })

Orderby asc
LINQ
from c in dbContext.Categories
       orderby c.CategoryName
       select c;
LAMDA
dbContext.Categories.OrderBy(c => c.CategoryName);

Orderby dsc
LINQ
from c in dbContext.Categories
       orderby c.CategoryName descending
       select c;
LAMDA
      dbContext.Categories.OrderByDescending(c => c.CategoryName);

Multiple orderby
LINQ
from c in dbContext.Categories
       orderby c.CategoryName , c.CategoryID
       select c;
LAMDA
      dbContext.Categories.OrderBy(c => c.CategoryName).ThenBy(c => c.CategoryID);

Orderby asc and dec
LINQ
from c in dbContext.Categories
       orderby c.CategoryName, c.CategoryID descending
       select c;
LAMDA
dbContext.Categories.OrderBy(c => c.CategoryName)
.ThenByDescending(c => c.CategoryID);

Filter
LINQ
from c in dbContext.Categories
       where c.CategoryID.Equals(1)
       select c;
LAMDA
dbContext.Categories.Where(c => c.CategoryID.Equals(1));

Filter with multiple criteria
LINQ
from c in dbContext.Categories
       where c.CategoryID.Equals(1) && c.CategoryName.StartsWith("A")
       select c;
LAMDA
dbContext.Categories.Where(c => c.CategoryID.Equals(1) &&
       c.CategoryName.StartsWith(
"A"));

Group By
LINQ
from c in dbContext.Categories
       group c by c.CategoryName into g
       select g;
LAMDA
dbContext.Categories.GroupBy(c => c.CategoryName)

Multiple group By
LINQ
from c in dbContext.Categories
       group c by new { c.CategoryID, c.CategoryName } into g
       select g;
LAMDA
dbContext.Categories.GroupBy(c => new { c.CategoryID, c.CategoryName })


Record Count
LINQ
(from c in dbContext.Categories
        where c.CategoryName.StartsWith("B")
       select c).Count();
LAMDA
dbContext.Categories.Count(c => c.CategoryName.StartsWith("B"));

Join
LINQ
from c in dbContext.Categories
       join p in dbContext.Products1 on c.CategoryID equals p.CategoryID
       select new
              {
                 CategoryName,
                 p.ProductID,
                 p.ProductName
              };
LAMDA
dbContext.Categories.Join(dbContext.Products1, c => c.CategoryID, P =>
       P.CategoryID,((c,p)=>
new {c.CategoryName,p.ProductID,p.ProductName}));

Wednesday, November 28, 2012

Entity framework and data iteration



We can write following piece of code to retrieve all records using DBSet. If we look at the database pro-filer we could see “SELECT * FROM Category” statement issued in the database.

var dbContext = new NorthwindEntities()
foreach (Category cat in dbContext.Categories)
{
Console.WriteLine(cat.CategoryName);
}

Some time we may need to iterate the same set of result set multiple times in a logical unit like below.

private void LogicalUnit()
{
          var dbContext = new NorthwindEntities()

foreach (Category cat in dbContext.Categories)
{
Console.WriteLine(cat.CategoryName);
}
foreach (Category cat in dbContext.Categories)
{
Console.WriteLine(cat.CategoryName);
}
}
Apparently everything looks fine but I wondered when I looked into the pro-filer and saw above SQL statement issued twice.
To avoid this, we can perform LINQ operation such as ToList() to copy the result set into a list and iterate the list whenever required.
var categories = dbContext.Categories.ToList();

foreach (Category cat in categories)
{
Console.WriteLine(cat.CategoryName);
}

foreach (Category cat in categories)
{
Console.WriteLine(cat.CategoryName);
}

This will hit the database only once to execute the query. We can refer the local result set for further reference. This way we can bring down the repeated database hit.

Monday, February 22, 2010

Reduce ASP.NET Page Size

This article I have posted in dotnetfunda.com on 22-Feb-2010. It says about how to reduce ASP.NET page size. Refer below the link for further details.
Reduce ASP.NET page size

The same tip and trick also published in Code Project

Sunday, February 14, 2010

ADO.NET DataTable as XML parameter to an Oracle/SQL Server Database Stored Procedure

I have posted this article in codeproject.com on 27th-Jan-2010. This article is all about how to convert ado.net datatable to XML and pass it as a parameter to backend. To get the detail please refer belo the link
ADO.NET DataTable as XML parameter to an Oracle/SQL Server Database Stored Procedure

Business Entity as XML

This article I have posted in dotnetfunda.com on 13th-Feb-2010. This is all about how to convert a business entity to XML. Refer below the link for details discussion.
Convert Business Entity or Entity collection as XML

File recovery from VM backup(Recovery Service vault)

Backup service can be enabled on VM through recovery service vault. This will primarily facilitate restoration of a VM from Backup when disa...