Get the list of names via Get Metadata activity

Priya Jha 871 Reputation points
2023-02-02T12:20:22.89+00:00

Hi All,

Below is the output of Get Metadata activity which contains name and type values for child items:

User's image

Is it possible to just get the name values and stored within an array variable without using any iteration.

Output = [csv1.csv,csv2.csv,csv3.csv,csv4.csv]

This was achieved by using ForEach and append variable, we dont want to use Iterations.

Azure Synapse Analytics
Azure Synapse Analytics
An Azure analytics service that brings together data integration, enterprise data warehousing, and big data analytics. Previously known as Azure SQL Data Warehouse.
4,913 questions
Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
10,666 questions
{count} votes

Accepted answer
  1. Nandan Hegde 32,256 Reputation points MVP
    2023-02-03T13:30:43.1066667+00:00

    Hey Priya,

    In addition to what @AnnuKumari-MSFT mentioned to be a clear way of splitting the file names ,

    You can also try the below crude way of converting the array into string and then replacing the values

    1st Set variable activity :

    @split(replace(replace(replace(replace(replace(replace(replace(replace(replace(string(activity('Get Metadata1').output.childItems),'[{',''),'}]',''),'{',''),'}',''),'"type":"Folder"',''),'"type":"File"',''),'"',''),'name:',''),',,',','),',')

    2nd Set variable activity :

    @take(variables('af'),add(length(variables('af')),-1))

    where af is an array variable set in the initial one

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. AnnuKumari-MSFT 32,831 Reputation points Microsoft Employee
    2023-02-03T10:16:14.89+00:00

    Hi Priya Jha ,

    Thankyou for using Microsoft Q&A platform and thanks for posting your question here.

    As I understand your question, you want to retrieve the name of files without iterating over the output json of get metadata activity. Please let me know if that is not the ask here.

    You can use a sql db/ azure sqb db connector in lookup activity to perform this job using openJSON function .

    declare @output varchar(max)
    
    set @output ='@{activity('Get Metadata1').output.childitems}'
    
    select concat('[',string_agg(filename,','),']')  as fileName from OpenJson(@output)
    
    with(filename varchar(100) '$.name')
    
    

    You can checkout this video for details about openJson function .


    Hope it helps. Please do consider clicking Accept Answer and Up-Vote for the same as accepted answers help community as well

    1 person found this answer helpful.

Your answer

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