0

I have a requirement to use the parameters inside the workflow parameters Object similar to below. But I am failing with the Azure Validation.

"parameters": {
    "$apprelatedparams": {
      "value": {
        "testId": "<GUID>",
        "testGroupName": "<GroupName>"
      }
    },
    "$connections": {
      "value": {
        "connectionName": {
          "connectionId": /test/@parameters['$apprelatedparams']['testId']/resourceGroups/@parameters['$apprelatedparams']['testGroupName']/providers/connectionName,
          "id": /test/@parameters['$apprelatedparams']['testId']/providers/testName
        }
      }
    }
  }

Here is the complete workflow with parameters object -

{
  "definition": {
    "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
    "actions": {
      "Response": {
        "inputs": {
          "body": "\"message\": \"Hello World!\"",
          "statusCode": 200
        },
        "runAfter": {},
        "type": "Response"
      }
    },
    "contentVersion": "",
    "outputs": {},
    "parameters": {},
  },
  "parameters": {
      "$apprelatedparams": {
      "value": {
        "testId": "TestID",
        "testGroupName": "GroupName"
      }
    },
     "$apprelatedparamstest": {
      "value": {
        "testsId": "@parameters['$apprelatedparams']['testId']",
        "testGroupsName": "@parameters['$apprelatedparams']['testGroupName']"
      }
    }
  }
}
Dev-VKP
  • 119
  • 2
  • 9

2 Answers2

0

Functions in expressions are called using parenthesis and not brackets. Therefore, you should transform your file into :

"parameters": {
    "$apprelatedparams": {
      "value": {
        "testId": "<GUID>",
        "testGroupName": "<GroupName>"
      }
    },
    "$connections": {
      "value": {
        "connectionName": {
          "connectionId": "/test/@parameters('apprelatedparams')['testId']/resourceGroups/@parameters('apprelatedparams')['testGroupName']/providers/connectionName",
          "id": "/test/@parameters('apprelatedparams')['testId']/providers/testName"
        }
      }
    }
  }

See also Expressions for Workflow Definition Language as it explains what outputs you should expect depending on how you construct the call.

Jul_DW
  • 1,036
  • 6
  • 20
  • I tried the way you mentioned, but it is failing validation and through errors like - @parameters('apprelatedparams')['testId'] not found. – Dev-VKP Nov 19 '21 at 10:59
  • Indeed, as per Swetha answer, some " " are missing ! Edited ! – Jul_DW Nov 19 '21 at 11:07
0

This is failing because of the structure of the json. Here is the json code that worked for me.

{
  "parameters": {
    "$apprelatedparams": {
      "value": {
        "testId": "<GUID>",
        "testGroupName": "<GroupName>"
      }
    },
    "$connections": {
      "value": {
        "connectionName": {
          "connectionId": "test/@parameters['$apprelatedparams']['testId']/resourceGroups/@parameters['$apprelatedparams']['testGroupName']/providers/connectionName",
          "id": "/test/@parameters['$apprelatedparams']['testId']/providers/testName"
        }
      }
    }
  }
}
SwethaKandikonda
  • 7,513
  • 2
  • 4
  • 18