Pass parameter to Azure Data Factory-ADF activity based on trigger - azure

I have Azure Data pipeline where I have to pass a parameter to Databricks activity. I have multiple Event based triggers (Updation of blob folder) added for that activity. When specific trigger gets activated, it should pass a parameter to Databricks activity and based on that notebook should run. Is there any way to pass parameter from Event based trigger to Databricks notebook activity?

Trigger gives out 2 parameters.
#triggerBody().fileName
#triggerBody().folderPath
You will have to add this to JSON code of trigger
"parameters": {
"FPath": "#triggerBody().folderPath"
}
Use this parameter as Pipeline variable #triggerBody().FPath and use that variable with other activities. Please refer to link below for detailed explanation
https://www.mssqltips.com/sqlservertip/6063/create-event-based-trigger-in-azure-data-factory/

Related

Is there any way to know the storage account name when ADF pipeline is triggered using ADF Storage Event Trigger

I am trying to create a ADF Pipeline which gets triggered as soon as a file in uploaded into a storage account. After triggering some operations are performed. I am able to get folder path and file name of the uploaded file. I also wanted to get the storage account name as it is useful in the future processes. Is there any way to extract that.
Currently, there is no option to fetch the storage account name directly from storage event triggers.
As a workaround, you can create a pipeline parameter to store the storage account name and pass the value from the event trigger when creating it.
Creating event trigger:
Here as we are selecting the storage name manually, pass the same
storage name value to the parameter.
Here, in the value option provide the storage account name.
Create a parameter in the pipeline to pull the storage name from the trigger.
Use the Set variable activity to show the parameter value which is passed from the trigger.

Send parameters in trigger ADF

I am working on a pipeline and we have DEV,QA and UAT env, so we are trying to use a parameter in the linked service in order to change the conection to the different DB (based on the environment)
we also have different triggers to run the pipeline based on the environment so my question is, is there a way to add a parameter in the trigger, execute the pipeline and send the linked service to connect to a specific environment?
You can have parameters to any type of triggers. Assuming you have a custom event trigger and SQL server as source, checkout the below example:
While creating SQL server linked service as a dataset, create string parameter for database name field
Create New parameter in dataset
Assign dataset parameter to Linked service parameter, which we will then use to store the data from trigger.
Create or use existing trigger, I am using a custom event trigger for example
A custom event trigger can parse and send a custom data payload to your pipeline. You create the pipeline parameters, and then fill in the values on the Parameters page. Use the format #triggerBody().event.data._keyName_ to parse the data payload and pass values to the pipeline parameters.
For a detailed explanation, see the following articles:
Reference trigger metadata in pipelines
System variables in custom event trigger
existing pipeline parameter.
Inside pipeline activity, specific your activity when used in source it would prompt for dataset parameter. Here use dynamic content and select the parameter holding trigger data.
Finally.. when the pipeline is triggered, trigger metadata is passed to pipeline parameter, which will be used in dataset property to switch between database dynamically in a server. Use multiple parameters similar to my example for use in different triggers and pipeline as per your environment.

How to reuse the Azure Data Factory pipeline for multiple users

I have a Azure data factory pipeline that is calling a Databricks notebook.
I have parameterized the pipeline and via this pipeline I am passing the product name to the databricks notebook.
Based on the parameter the Databricks will push the processed data into the specific ADLS directory.
Now the problem is- How do I make my pipeline aware that which parameter need to pass to the Databricks.
Example: If I pass the Nike via the adf to the databricks then my data would get pushed into Nike directory or If I pass Adidas then data would get pushed into Adidas directory.
Please note that I am triggering the ADF from the automation account.
As I understood, you are using product_name = dbutils.widgets.get('product_name') statement in the databricks notebook to get the param and based on that param you process the data. The question is how to pass different params to the notebook? You create one adf pipeline and you can pass different params to the triggers that execute the adf pipeline.
Create ADF pipeline
Adf pipeline
create trigger that will pass params to the ADF pipeline
triggers
This way you will have 1 ADF pipeline with multiple instances of it with different params like Adidas, Nike etc.

Pass a value from inside the Azure ADF pipeline to a PowerShell where the pipeline invoked

I want to do some steps in my PowerShell based on a value from an Azure ADF(Azure Data Factory) pipeline. How can I pass a value from an ADF pipeline to the PowerShell, where I invoked this ADF Pipeline? So that, I can do the appropriate steps in the PowerShell based on a value I received from ADF pipeline.
NOTE: I am not looking for the run-status of the pipeline (success, failure etc), but I am looking for some variable-value that we get inside a pipeline - say, a flag-value we obtained from a table using a Lookup activity etc.
Any thoughts?
KPK, the requirements you're talking about definitely can be fulfilled though I do not know where does your Powershell scripts run.
You could write your Powershell scripts in HTTP Trigger Azure Function,please refer to this doc. Then you could get the output of the pipeline in Powershell:
https://learn.microsoft.com/en-us/powershell/module/azurerm.datafactoryv2/invoke-azurermdatafactoryv2pipeline?view=azurermps-4.4.1#outputs.
Then pass the value you want to HTTP Trigger Azure Function as parameters.

Azure Data Factory Copy Data dynamically get last blob

I have an Azure Data Factory Pipeline that runs on a Blob Created Trigger, I want it to grab the last Blob added and copy that to the desired location.
How do I dynamically generate the file path for this outcome?
System Variables
Expressions and Functions
"#triggerBody().folderPath" and "#triggerBody().fileName" captures the last created blob file path in event trigger. You need to map your pipeline parameter to these two trigger properties. Please follow this link to do the parameter passing and reference. Thanks.

Resources