How we Pass Start and End Date in REST API URL as parameter in Azure Data Factory

manish verma 516 Reputation points
2024-01-01T17:12:32.2533333+00:00

Hi All,

we are using Microsoft API in Azure data factory copy activity example given below

https://management.azure.com/subscriptions/{/subscriptionsId}/providers/Microsoft.Consumption/usageDetails?$expand=meterDetails,additionalProperties&$filter=properties/usageEnd ge '2023-12-01' AND properties/usageEnd le '2023-12-31' &$top=30&api-version=2019-01-01

Here we can see two date Parameter 2023-12-01 and 2023-12-01, we need to replace this with variable adddays(utcnow(),-1) as start date and utcnow() as end date

please help

Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
11,442 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Konstantinos Passadis 19,496 Reputation points MVP
    2024-01-01T17:26:38.01+00:00

    Hello @manish verma !

    I can see you need to add Date parameters into your API Call to replace this with variable adddays(utcnow(),-1) as start date and utcnow() as end date

    Use this for start

    @{formatDateTime(adddays(utcnow(),-1), 'yyyy-MM-dd')}. This expression calculates the date one day before the current UTC date and formats it as 'yyyy-MM-dd'.

    And ;

    @{formatDateTime(utcnow(), 'yyyy-MM-dd')}. This expression gets the current UTC date and formats it as 'yyyy-MM-dd'.

    At the end combined it should look like this:

    https://management.azure.com/subscriptions/{/subscriptionsId}/providers/Microsoft.Consumption/usageDetails?$expand=meterDetails,additionalProperties&$filter=properties/usageEnd ge '@{formatDateTime(adddays(utcnow(),-1), 'yyyy-MM-dd')}' AND properties/usageEnd le '@{formatDateTime(utcnow(), 'yyyy-MM-dd')}' &$top=30&api-version=2019-01-01

    Can you please try ? I have not been able to try this out so give it a go and kindly provide your feedback !


    I hope this helps!

    The answer or portions of it may have been assisted by AI Source: ChatGPT Subscription

    Kindly mark the answer as Accepted and Upvote in case it helped!

    Regards


  2. Konstantinos Passadis 19,496 Reputation points MVP
    2024-01-02T16:44:26.65+00:00
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.