daxu
daxu

Reputation: 4074

how to specify a variable/parameter in my logic app's arm template?

I am creating an Arm template for a logic app. This logic app needs to delete some old entries in azure table (say 10 or 20 days old).

In my arm template, if I do this, it works.

"queries": {
            "$filter": "Timestamp le datetime'@{addDays(utcNow(),-31)}'"
  }

But ideally I want to do this:

"queries": {
            "$filter": "Timestamp le datetime'@{addDays(utcNow(),parameters('RetainDay'))}'"
   }

Basically use a parameter to control the amount of days to check. I define this parameter as:

 "parameters": {
    "RetainDay": {
      "type": "int"
    }
  }

When I deploy this, the parameters('RetainDay') isn't replaced to the parameter value. Instead it just stays same as:

Timestamp le datetime'@{addDays(utcNow(),parameters('RetainDay')

So I must be using the wrong syntax.

Can someone point it out?

Upvotes: 1

Views: 2294

Answers (3)

George Chen
George Chen

Reputation: 14324

I see your template only set the parameter retionday type, you don't set the value. So go to parameter set the defaultValue like the below picture.

enter image description here

And I just use the this Filter Query Timestamp le datetime'@{addDays(utcNow(),parameters('retionday'))}', it will replace the time.

enter image description here

So please have a try, hope this could help you.

Upvotes: 0

4c74356b41
4c74356b41

Reputation: 72151

You need to use a concat() function to achieve string concatenation and variable expansion:

"$filter": "[concat('Timestamp le datetime\'@{addDays(utcNow(),', parameters('RetainDay'), ')}\'')]"

i think you can escape ' with \, if not, you can create a variable with the value ' and use that instead.

Upvotes: 0

AdAstra
AdAstra

Reputation: 1984

You need to connect the 'Logic Apps template parameter' together with the 'ARM deployment template parameter', as much as it looks like the one and same variable, it is two parameters that work together. In my solution, I have a parameter called 'CustomVariableName'

Solution file

Passing the parameter Logic App Designer

Declaring the CustomVariableName in the "logic app code" and in the ARM template Logic App Code View

Value in parameters file Logic App parameters file

Deployed Logic App in Azure Deployed Azure Logic App

Postman POST response from hitting the HTTP trigger(instead of value: 'DefaultValue') enter image description here

Upvotes: 2

Related Questions