Welcome to part two of my blog series on Azure Data Factory. In the first post I discussed the get metadata activity in Azure Data Factory. Now you are going to see how to use the output parameter from the get metadata activity and load that into a table on Azure SQL Database.
Check out part one here: Azure Data Factory – Get Metadata Activity
In this blog post you are going to learn the following:
- How to execute a stored procedure in Azure Data Factory.
- How to use the output parameters from the Get Metadata task as input parameters for a stored procedure.
Setting up the Stored Procedure Activity in Azure Data Factory
I am going to pick up where I left on in the last blog and add the stored procedure activity to my existing pipeline.
- Add the stored procedure activity to the pipeline, it’s found under “General”.
- Next, connect the two activities, the stored procedure will only execute following a successful completion of the get metadata activity.
- Click on the stored procedure activity to get to the properties window and then click on “SQL Account”.
- Under SQL account select the linked service to your Azure SQL Database. If you haven’t already created a linked service, click + new to create a new one.
- Now click the “Stored Procedure” tab in the properties window.
- Choose your stored procedure from the dropdown menu. This dropdown will display all stored procedures on your Azure SQL DB. The stored procedure in this blog is inserting the modified date of the file into a table.
- Click on import parameter. This will import any parameters found in your stored procedure. Notice that the parameter ModifiedDate is returned in the parameter list.
Dynamically setting the Value
The last step is to now pass a value into the parameter ModifiedDate so that the table can be properly updated. The Modified Date value produced from the Get Metadata activity is the value we want to pass into the stored procedure. You can manually type in the output parameter reference or you can use the option to add dynamic content.
- Add dynamic content by either clicking the hyperlink “add dynamic content [Alt + P]” or by clicking in the Value box and then using the hotkey [Alt + P].
- Scroll to the very bottom of this dynamic content list and then click “Get Metadata1” under activity outputs. Unfortunately, this does not generate the full expression for returning the last modified date of the property. We still need to specify which output we want here.
- Complete the expression by adding .lastModified.
- Click Finish.
Tip: Getting the exact name of the output parameter can be challenging, we discussed how to find the property name in the get metadata blog post. If you missed that blog, or forgot, now would be a good time to go back and do a quick review.
As the last step, debug and test your pipeline! Thanks for reading this blog and please check back often!
4 thoughts on “Azure Data Factory – Stored Procedure activity”
Pingback: Azure Data Factory – Lookup Activity – Mitchellsql
Pingback: Azure Data Factory – If Condition activity – Mitchellsql
Pingback: Azure Data Factory–Copy Data Activity – Mitchellsql
Pingback: Azure Data Factory–Filter Activity – Mitchellsql