问题
I download json files from a web API and store them in blob storage using a Copy Data activity and binary copy. Next I would like to use another Copy Data activity to extract a value from each json file in the blob container and store the value together with its ID in a database. The ID is part of the filename, but is there some way to extract the filename?
回答1:
You can do the following set of activities:
1) A GetMetadata activity, configure a dataset pointing to the blob folder, and add the Child Items in the Field List.
2) A forEach activity that takes every item from the GetMetadata activity and iterates over them. To do this you configure the Items to be @activity('NameOfGetMetadataActivity').output.childItems
3) Inside the foreach, you can extract the filename of each file using the following function: item().name
After this continue as you see fit, either adding functions to get the ID or copy the entire name.
Hope this helped!
回答2:
After Setting up Dataset for source file/file path with wildcard and destination/sink as some table
- Add Copy Activity setup source, sink
- Add Additional Columns
- Provide a name to the additional column and value "$$FILEPATH"
- Import Mapping and voila - your additional column should be in the list of source columns marked "Additional"
来源:https://stackoverflow.com/questions/53764072/retrieve-blob-file-name-in-copy-data-activity