This is today's reality that enterprise data is not stored in one or two locations. In today's digital era, data is distributed across on-premises, multiple cloud environments or in one or more software as services. The big question is how to manage and classify this data across multiple locations. The answer is "Azure Purview".
Azure Purview is Microsoft's unified data governance solution across storage locations with following features:
1. Data discovery - Birds view of your data
2. Data classification Ex: Financial, Personal, Government
3. End to end data lineage
4. Insight into location and sensitive data movement across locations
5. Comprehensive security and data compliance built-in
6. Search by business & technical terms
7. Technical & business metadata management
8. Powerful insight into data by leveraging AI, BI, Analytics, Machine Language etc.
9. Empower Data Scientists
Enjoy Learning !
Tuesday, December 21, 2021
As part of my cloud journey, I got to know about this free online tool Azure DevOps Demo Generator from Microsoft.
It is a great tool from Microsoft that simplify working Azure DevOps
It helps you to create project in your DevOps organization based on the template you choose from the out of box templates comes along with the tool
The DevOps project created using this tool comes with sample content that includes source code, pipeline definitions, agile work items etc.
Integration of both using Azure DevOps pipeline makes Azure Development smooth. Loving it.
Sunday, December 4, 2016
Context:Given below a grid of rules applicable for different screen in a financial application.
Objective: To come up with a design that supports the implementation of the given requirement.
Design:
Thursday, December 1, 2016
Resource level locks in Sql Server
Row
Key
Table
Page
Extent
Partition
Database
Models of locks
Shared Lock(S) - Can be held by any processes
Update Lock(U) - Mix of shared and exclusive lock
Exclusive Lock(X) - Can be held by only one process
Intent Lock(I)
Intent Shared(IS)
Shared with Intent Exclusive(SIX)
Intent Exclusive(IX)
Bulk Update Lock(BU)
Schema Lock
Schema Stability (Sch-S) - It is applied while generating the execution plan
Schema Modification (Sch-M) - It is applied while executing a DDL Statement
Transaction Isolation Levels
Pessimistic
Read Uncommitted (NOLOCK) - No shared lock acquired
Read Committed (READCOMMITTED) (Default) - Shared lock acquired and released immediately
Repeatable Read (REPEATABLEREAD) - Lock till the end of transaction
Serialization (HOLDLOCK) - Lock till the end of transaction and a range of rows
Optimistic
Snapshot
Snapshot Read Committed
sys.dm_tran_locks view keeps track of a Lock and resource identification
sys.dm_exec_sessions view provides transaction isolation level in use for the current process
Writting Custom ASP.NET Trace Messages using System.Diagnostics.TraceSource class and trace sources
Writting Custom ASP.NET Trace Messages using System.Diagnostics.Trace class
PRE-Requisite(Trace Complier Constant) : Trace statements (Custom tracing) require the TRACE compiler constant, but it’s on by default and you can verify that in the Build tab of the project properties window
The problem is that this setting in the .csproj file only applies to .cs files. ASP.NET uses a different compile process for .cshtml files (or .aspx files in Web Forms), and the settings for that compile process are in the Web.config file. If you don’t explicitly specify the TRACE constant there, tracing method calls in .cshtml views are ignored.
Below is an example of what you have to add to the application Web.config file for a Visual Studio project that targets .NET 4.5, in order to define a TRACE constant for the .cshtml compiler:
ASP.NET Application Level Tracing
Web.Config entries
C# Code
using System.Diagnostics;
public class AccountController : Controller
{
public ActionResult Index()
{
TraceSource source = new TraceSource("AccountController");
source.TraceEvent(TraceEventType.Warning, 100, "This is message logged from Account Controller");
return View();
}
}
Writting Custom ASP.NET Trace Messages using System.Diagnostics.Trace class
using System.Diagnostics;
public class AccountController : Controller
{
public ActionResult Index()
{
Trace.WriteLine("This is message logged from Account Controller");
return View();
}
}
When a user opens his web browser and makes a request to a ASP.NET Web Application for which a cookie based Session is enabled, Server generates a new SessionId and sends it to web Browser as a cookie with the name "ASP.NET_SessionId". Applications in the same DNS domain share the same Session Id and cookie. When the user browses within the same DNS domain, the browser sends same Session Id and cookie to the domain. Since it is shared across applications in a domain, so ASP.NET doesn't remove the cookie when the session is expired or Session.Abandon() is invoked. Because of this design, the code that is used to check if a Server Session is actually expired doesn't work properly. Generally we use following code snippet to check if session is expired.
if (Session.IsNewSession)
{
if (Request.Headers("Cookie") != null && Request.Headers("Cookie").IndexOf("ASP.NET_SessionId") >= 0)
{
return true;
}
}
return false;
As ASP.NET doesn't remove the cookie "ASP.NET_SessionId" when the session is expired, so the above code doesn't check correctly. To ensure the above code works properly, the developer has to manually remove the session cookie in the event of a Session Expiry by using the following code.
[DataContract]
[KnownType(typeof(Student))]
[KnownType(typeof(Teacher))]
public class Person
{
[DataMember]
public string Name{get; set;}
}
//Serialize all derived types of Person.
[DataContract]
[KnownType("GetDerivedTypes")]
public class Person
{
[DataMember]
public string Name{get; set;}
static IEnumerable GetDerivedTypes()
{
return from type in typeof(Person).Assembly.GetTypes()
where typeof(Person).IsAssignableFrom(type)
select type;
}
}
[DataContract]
public class Student: Person
{
[DataMember]
public string Grade{get; set;}
}
[DataContract]
public class Teacher : Person
{
[DataMember]
public string Subject {get; set;}
}
public class MySerializer
{
var mySerializer = new DataContractSerializer(typeof(Person));
var stream = new MemoryStream();
var writter = new XMLTextWritter(stream, Encoding.UTF8) {Formatting = Formatting.Indented};
mySerializer.WriteObject(writter, new Teacher());
writter.flush();
Console.Writeline(stream);
}
var TaxCalculator = function(data){
//private members
var name = data.Name;
var basic = data.Basic;
var allowances = data.Allowances;
var deductions = data.Deductions;
var result = 0;
return {
//public members
CalculateTax : function(){
result = ((basic + allowances) - deductions)*0.1;
return result;
}
};
}
$(document).ready(function(){
var data = {Name:Alex, Basic:4000, Allowances:600, Deductions: 400};
var calc = new myNamespace.TaxCalculator(data);
alert(calc.CalculateTax());
});
To ensure that your actions are called through only Https, you can decorate your action methods with RequireHttps attribute. But this will not work in your development server as usually the development box is not configured with HTTPS. Basically you need to to apply this attribute conditionally based on a configurable item. This can be achieved by creating a custom class that is derived from RequireHttpsAttribute and by overridding its OnAuthorization().
using System;
using System.Configuration;
using System.Web;
using System.Web.Mvc;
public class RequireSslAttribute : RequireHttpsAttribute
{
private const string EnableSslKey = "EnableSSLForMySite";
public override void OnAuthorization(AuthorizationContext filterContext)
{
if (filterContext == null)
{
throw new ArgumentException("filterContext");
}
if (!IsHttpContextNull(filterContext) && !IsEnableSsl())
{
return;
}
BaseOnAuthorization(filterContext);
}
protected virtual void BaseOnAuthorization(AuthorizationContext filterContext)
{
base.OnAuthorization(filterContext);
}
protected virtual bool IsHttpContextNull(AuthorizationContext filterContext)
{
return filterContext.HttpContext == null;
}
protected virtual bool IsEnableSsl()
{
var enableSslForMySite = HttpRuntime.Cache.Get(EnableSslKey);
bool isEnableSsl = false;
if (enableSslForMySite == null)
{
string configEnableSsl = ConfigurationManager.AppSettings[EnableSslKey] ?? string.Empty;
isEnableSsl = (configEnableSsl.ToLower() == "true");
HttpRuntime.Cache.Insert(EnableSslKey, isEnableSsl);
}
else
{
bool.TryParse(enableSsl.ToString(), out isEnableSsl);
}
return isEnableSsl;
}
}
BaseController
[RequireSsl]
public abstract class BaseController : Controller
{
}
There are 2 ways by which the user can come back to a deleted entity. 1. By typing the Url in the browser address bar. 2. By clicking on the browser back button just after deleting the entity. While option-1 is already taken care of by redirecting the user to an Add New screen but the second option certainly allows the user to update an entity that is already deleted. So the solutions described here are applicable for option-2 scenario.
Solution – 1: By tracking a deleted flag using a Hidden Field.
The value of a hidden field is retained when you use the browser back/Forward button. So the value of a hidden field can be used to check if the user has clicked the browser back button to reach the current page.
The solution can be implemented by following three simple steps.
A hidden field with default value “0” is added to all UI which provides the provision to delete an entity. This doesn’t work if we add it programmatically. It has to be added in the .cshtml file.
Inside the success callback of the delete method, set the value of the hidden field to “1”.
On document load, check the value of the hidden field. If it is “1” then the current entity is a deleted entity.
Solution – 2: Using History.js
The idea here to use HTML5 History/State API (pushState, getState etc.) to modify the history entries by replacing the current state with a delete state after a delete operation is over. pustState() & replaceState(0 are the two methods used to add/modify the history entries. This changes the referrer that gets used in the HTTP Header for XMLHttpRequest object. Then use the HTML5 onhaschange event to check if the current state of the entity matches with any of the previous deleted state in the History.
During this research it is established that Internet Explorer version 9 or less doesn’t supports HTML5 History/State API. Further research on this lead us to History.js plug-in which gracefully supports HTML5 History/State API in all browsers including the browsers that don’t support HTML5. So the POC is done based on the same idea using the History.js.
Here are the steps to implement this solution.
Add code to modify the history entry of the current state with a deleted state inside the success callback of the delete Ajax call.
Bind a custom function to the statechange event to check if the current state matches with any previous deleted state in history. If a match is found then take necessary action to alert the user about it.
Conclusions:
Based on the ease of development, it seems that Hidden Field approach is the best option available currently with only additional burden of adding a hidden field on all UI that provides the provision to delete an entity except search screens.
Altering a SQL Table to add a column on Production can be risky affair as it contains vital production data in it.
The sql script given below gives an idea how to go for it. In the example below, the table is getting altered to add the new column [Column6].
USE <>
GO
BEGIN TRANSACTION
SET QUOTED_IDENTIFIER ON
SET ARITHABORT ON
SET NUMERIC_ROUNDABORT OFF
SET CONCAT_NULL_YIELDS_NULL ON
SET ANSI_NULLS ON
SET ANSI_PADDING ON
SET ANSI_WARNINGS ON
COMMIT
BEGIN TRANSACTION
GO
CREATE TABLE dbo.Tmp_
(
[Key] [int] IDENTITY(1,1) NOT NULL,
[Column1] [int] NOT NULL,
[Column2] [int] NOT NULL,
[Column3] [int] NULL,
[Column4] [int] NOT NULL,
[Column5] [varchar](50) NULL,
[Column6] [int] NULL
) ON [PRIMARY]
GO
ALTER TABLE dbo.Tmp_TableName SET (LOCK_ESCALATION = TABLE)
GO
SET IDENTITY_INSERT dbo.Tmp_TableName ON
GO
IF EXISTS(SELECT * FROM dbo.TableName)
EXEC('INSERT INTO dbo.Tmp_TableName ([Key],[Column1], [Column2],[Column3], [Column4], [Column5])
SELECT [Key],[Column1], [Column2],[Column3], [Column4], [Column5] FROM dbo.TableName WITH (HOLDLOCK TABLOCKX)')
GO
SET IDENTITY_INSERT dbo.Tmp_TableName OFF
GO
DROP TABLE dbo.TableName
GO
EXECUTE sp_rename N'dbo.Tmp_TableName', N'TableName', 'OBJECT'
GO
ALTER TABLE dbo.TableName ADD CONSTRAINT
PK_TableName PRIMARY KEY CLUSTERED
(
[Key]
) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
ALTER TABLE [dbo].[TableName] WITH CHECK ADD CONSTRAINT [FK_TableName_FKTable1] FOREIGN KEY([Column1])
REFERENCES [dbo].[FKTable1] ([Key])
GO
ALTER TABLE [dbo].[TableName] WITH CHECK ADD CONSTRAINT [FK_TableName_FKTable2] FOREIGN KEY([Column2])
REFERENCES [dbo].[FKTable2] ([Key])
GO
ALTER TABLE [dbo].[TableName] WITH CHECK ADD CONSTRAINT [FK_TableName_FKTable3] FOREIGN KEY([Column3])
REFERENCES [dbo].[FKTable3] ([Key])
GO
ALTER TABLE [dbo].[TableName] WITH CHECK ADD CONSTRAINT [FK_TableName_FKTable14] FOREIGN KEY([Column4])
REFERENCES [dbo].[FKTable4] ([Key])
GO
ALTER TABLE [dbo].[TableName] WITH CHECK ADD CONSTRAINT [FK_TableName_Table5] FOREIGN KEY([Column5])
REFERENCES [dbo].[FKTable5] ([Key])
GO
COMMIT
Example:
Regular Expression to find and replace all occurrences of CAST(0x0000A1D7010C33B5 AS DateTime) in a .sql file using Find/Replace dialog of SQL Server Management Studio.
SQL Query - How to get all notes comma separated group by customer
NoteKey
CustomerKey
Note
LastEditedTime
1
18736673
Accout access error, Contact Technical team.
01/02/2013
SELECT n1.CustomerKey, (SELECT ','+ n2.Note+ ' Last Edited Time:' + convert(varchar(26),n2.LastEditedTime)
FROM Note n2
WHERE n1.CustomerKey= n2.CustomerKey
ORDER BY CustomerKey, Note
FOR XML PATH('')) AS CustNote
FROM Note n1
Group By n1.CustomerKey
Deba Khadanga has extensive rich experience in Architecture, Design and implementation of Enterprise Solutions on highly Distributed computing platforms primarily using Microsoft and Azure Cloud technologies. Nowadays, he works with Capgemini India Pvt. Ltd as Cloud Architect. His work experience also includes experience in building Cloud MS Practice capability | Azure CoE capability | pre-sales support for cloud migration and modernization | RFP, RFI response in financial domain. You can send an email to debapkhadanga@gmail.com.