Home > Net >  Use date parameter in Azure Pipeline FetchXML query
Use date parameter in Azure Pipeline FetchXML query

Time:01-11

in my Azure Data Factory pipeline, I have a parameter, let's call it 'pDate', and it has a default value of 2023-01-01.

But every time I run the pipeline (copy data), I want to be able to change it.

I can do that with a variable as shown below (date1 variable), but then I have to change the value of the variable.

How could I insert a parameter here instead?

<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false"> 
<entity name="my_attachment"> 
<all-attributes/>  
<filter type="and"> 
<condition attribute="createdon" operator="on-or-after" value="@{variables('date1')}" /> 
</filter>  
</entity> 
</fetch>

CodePudding user response:

  • Parameters are constants across the particular pipeline. So, you can't change its value within the pipeline.
  • A variable with static value (say 2023-01-01) is a parameter itself. Every time you execute the pipeline, the same value will be assigned to the variable making its functionality similar to parameter.
  • If there is a pattern for your date like created on or before 10 days (from today's date), then you can build a dynamic pipeline expression for this value. So, each time you run the pipeline, the value would be dynamic as required.
  • If there is no such pattern, then you have to make use of parameters. You can still change the value each time you run the pipeline.
  • When you try to trigger or debug the pipeline, the pipeline run tab will prompt you to enter the value for your parameter. You can simply give the required value and proceed accordingly.
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
<entity name="my_attachment">
<all-attributes/>
<filter type="and">
<condition attribute="createdon" operator="on-or-after" value="@{pipeline().parameters.req_date}" />
</filter>
</entity>
</fetch>

enter image description here

  • Related