0

I am developing an ADF pipeline that looks through a set of ADLS directories and extracting the name and last modified dates for each folder. I have written the extracted information to a "Set Variable" activity, my major issue now is how to pass these arrays into an Azure SQL table. I have tried using a stored procedure, but it does not write any records, I also tried copy activity but I wasn't sure how to configure the parameters.

Here is what I have tried:

enter image description here

"Set variable1" collects all the records appended by the inner Append variable activity.

The output in the set variable is like this:

{
    "name": "allFiles",
    "value": [
        "FileName,LastUpdated",
        "final_directory1,2024-11-15T10:50:23+00:00",
        "all_entry_levels,2025-07-11T20:58:34+00:00",
        "final_directory,2025-07-11T21:01:38+00:00",
        "groceries_list,2025-07-11T21:04:44+00:00",
        "all_onetime_records,2025-07-11T21:04:58+00:00",
        "industries_list,2025-07-11T21:05:11+00:00",
        "SNAPSHOT_last,2025-07-11T21:05:25+00:00",
        "LATEST_information_farming,2025-07-11T21:05:38+00:00"
    ]
} 

For the copy activity, I created a dummy csv file and pointed the dataset to it, then mapped an additional column to the set variable

enter image description here

At this point, I have no idea what to do, I know I need to map the columns but I am a bit confused as to how.

Any help would be really appreciated, either with copy activity or stored procedure activity.

1
  • On a side note: be aware that the LastModifiedDate of a folder in ADLS is only in reference to the Folder and not to its contents. If you add/change/delete an item inside the folder it will NOT update the LastModifiedDate of the folder itself. Commented Jul 15 at 20:13

1 Answer 1

0

You can use stored procedure activity to insert the array data into table.

Modify the array result by removing the "FileName,LastUpdated" and also used |(pipe) in place of ,(comma) between the 2 fields as shown below ArrayOutput

Now assign this array variable to stored procedure activity, since it is array convert it into string either by using @string(variables('AllFiles')) or @{variables('AllFiles')} as shown below SPParameter

Create a table to store this data

CREATE TABLE [dbo].[ADLSMeta](
    [FileName] [varchar](max) NULL,
    [LastUpdated] [datetime2](7) NULL
) 
GO

Stored proc to process this array data

Create PROCEDURE dbo.Insertmetadata
@metadata varchar(max)
as
BEGIN
SET NOCOUNT ON;

INSERT INTO [dbo].[ADLSMeta]([FileName],[LastUpdated])
SELECT b.[FileName],b.[LastUpdated]
FROM OPENJSON(CONCAT('[',REPLACE(@metadata,',','],['),']')) a
CROSS APPLY OPENJSON(CONCAT('[',REPLACE(a.[value],'|','","'),']'))
WITH([FileName]   VARCHAR(max)  '$[0]'
    ,[LastUpdated]  datetime2(7)  '$[1]'
    ) b;


END

The result look like this

Result

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.