Use Data factorys to archive SQL data to json files on a blob storage

Pascal Jahr 21 Reputation points
2022-11-09T09:16:13.583+00:00

Hey,

I am completely new to data factorys but though that I can use them to fulfill my archiving requirements.
I have a small azure sql schema with only 5-6 tables in it. Those tables contain a lot of data though and that data needs to be archived on a scheduled basis. Archived means, delete rows which are older then 12 month (there is a column that can be used for the check) from the table and put those rows in a json file stored on a blob storage.
Looking into data factories I can:

  • set up the azure sql as a source dataset
  • create a filter to filter the source table based on the requirement "older then 12 month"
  • create a sink that fill push the filtered rows to a json

What is unclear to me is the deleting part. The rows I pushed to the json should be deleted from the DB. But how? I added an "alter" step with "delete if" but the table is not touched at all.

Can someone help?

Azure SQL Database
Azure Blob Storage
Azure Blob Storage
An Azure service that stores unstructured data in the cloud as blobs.
Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
0 comments No comments
{count} votes

Answer accepted by question author
  1. ShaikMaheer-MSFT 38,556 Reputation points Microsoft Employee Moderator
    2022-11-10T15:10:02.66+00:00

    Hi @Pascal Jahr ,

    Thank you for posting query in Microsoft Q&A Platform.

    You can use Copy activity to copy rows older than 12 months to Json file in blob storage and then use script activity to perform delete rows operation on SQL table.

    Below are the detailed Implementation details.
    Step 1: Copy activity, under Source tab use dataset pointing to your SQL Table. Select Query option there and write query that gives you rows older than 12 months.
    259076-image.png

    Step 2: Script Activity, write SQL query to delete older rows from table in it. Please check this video to know more about script activity.
    259084-image.png

    Hope this helps. Please let me know if any further queries.

    -----------

    • Please don't forget to click on 130616-image.png or upvote 130671-image.png button whenever the information provided helps you. Original posters help the community find answers faster by identifying the correct answer. Here is how
    • Want a reminder to come back and check responses? Here is how to subscribe to a notification

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.