I have a requirement to slice "Dev" from below variable vmName in Azure logicapp
variable information :
- Name : vmName
- Type : String
- Value : Dev-Testing-2
When i tried with below approach/expression :
slice(split(variables('dsvmName'),'-'),1)
error : The template language function 'slice' expects its first parameter to be of type string. The provided value is of type 'Array'. Please see
CodePudding user response:
Try this (untested) ...
split(variables('dsvmName'),'-')?[0]
That will retrieve the first item in the array when you split it by a hyphen.
CodePudding user response:
I have reproduced in my environment and got expected results and followed below process:
Firstly, I have taken a http trigger and then initialized as below:
Then, again I initialized as below:
indexOf(variables('vmName'), '-')
Then again initialized as below to get output:
substring(variables('vmName'),0, int(variables('emo')))
Output: