How to Scaleup and ScaleDown Azure SQL database using Azure data factory?

 Sometimes we face the problem to Scaleup/ ScaleDown the Azure SQL DB using code in our adf pipeline. We handle it manually most of the times but what if our adf pipeline is triggered by Schedule trigger and we need to Scale up / down DB as per Start/ finish of pipeline copy activity?


here is the solution.


Create a proc to Select and Update Current DTU of Azure SQL DB.


Create Proc SelectUpdate

( @CurrentDtu varchar (10) output , @DTUtoUpdate varchar (10)) -- S12 - 3000


as

begin

SELECT

@CurrentDTU =slo.service_objective

FROM sys.databases d

JOIN sys.database_service_objectives slo

ON d.database_id = slo.database_id


ALTER DATABASE [TestAzureDB] MODIFY( SERVICE_OBJECTIVE=@DTUtoUpdate)


end


adf pipeline steps


1- call the proc (@cDTU output,'S12') to select current DTU first n then update DTU --- call this from lookup activity and it will set value into @cDTU variable


2- use wait activity - bcz DB takes 1 min to reflect changes


3 - copy data activity


4 - call same proc again by passing value of current DTU variable to reset back to old dtu


I hope it will helpful


#azuresql #adf #database #data #azure #Mission100AzureDataEngineer

Comments

Popular posts from this blog

Performance optimization in Copy data activity in Azure

Azure blob Storage interview questions

Why do we have two keys in storage account and need for rotate them ?