
Find the public void Main() method and edit it so it contains the following code: public void Main() Click the ellipsis in the ReadOnlyVariables property textbox to open the Select Variables dialog:Ĭlick the OK button. Leave the Script Language set to Microsoft Visual C#. Rename the Script Task “SCR Log Values”:ĭouble-click the Script Task to open the Script Task Editor. Change the Name of the Variable to FileName, accept the defaults for all other properties and click the OK button:Ĭlick the OK button to close the Foreach Loop Container editor.ĭrag a Script Task from the SSIS Toolbox into the Foreach Loop Container named FOREACH File in SourceFolder. When the Add Variable dialog displays, make sure the Container is set to the Package level. Navigate to the Variable Mappings page and click “” from the Variable dropdown: Change the Files specification to “*.csv” and make sure the Retrieve File Name “Fully qualified” option is selected: Click the Evaluate Expression button to see the default for this parameter in the Evaluated value textbox.Ĭlick OK a couple times to return to the Foreach Loop Container Editor. Click $Package::SourceFolder and drag it to the Expression textbox. Select the Directory Property from the Property dropdown and click the ellipsis in the Expression textbox to open the Expression Builder window:Įxpand Variables and Parameters. These expressions, by the way, are Enumerator-specific. This opens the Property Expressions Editor window.

Just beneath the Enumerator property dropdown, please find the Expressions property and click the ellipsis for Expressions shown circled in the image below: Rename the Foreach Loop Container “FOREACH File in SourceFolder”:ĭouble-click the Foreach Loop Container to open the editor. In fact, you could do everything I’m showing you in this demo using a single Script Task.ĭrag a Foreach Loop Container from the SSIS Toolbox onto the Control Flow surface. Please realize you can accomplish the same thing using an SSIS Script Task and a little. One is more “SSIS-y,” the other is more “script-y.” I’m going to show you the “SSIS-y” way. We will use the SourceFolder parameter to set our directory to “watch” for a file. Rename the default SSIS Package SnifferPackage.dtsx: An SSIS PackageĬreate an SSIS Project named SnifferDemo:

When it’s time to test, I will copy the file from the staging directory and paste it into the data directory. I’ve placed my file in a staging directory: I created LeonardsAndPets.csv, shown above. Sniffer Demoīegin by creating a file that contains some data. I can hear you thinking, “What does a sniffer do, Andy?” I’m glad you asked! The sniffer executes every now and then, checks for some condition – like the presence of a file in a directory – logs what it finds, and then responds accordingly.

You can use a pattern I call the Sniffer Design Pattern.
Azure functions filewatcher how to#
The Snifferīut what if all you really know is SSIS? Maybe you don’t know how to write a service maybe you don’t have time to learn. If you really, really need to start loading the contents of a file within milliseconds of its arrival, please write a service. I’ve seen way too many memory leaks to feel comfortable with an SSIS package running forever. Have you seen the SSIS File Watcher demos where a developer puts an SSIS package in an infinite loop while it waits for a file to show up in a directory? It’s a popular pattern, especially when files are FTP’d (or SFTP’d) to enterprises for processing.
