After initially designing your Logic App in the Azure Portal, you may wish to port it to Visual Studio 2017 to manage the template under a source control repository and to further develop it from Visual Studio.
After porting the code, you may encounter some of the following errors when trying to save or deploy your Logic App from Visual Studio.
Error: …the string character ‘@’ at position ‘0’ is not expected.
This is fairly easy to identity as Visual Studio highlights the code which it thinks the syntax is incorrect as shown below. Remember this code was ported over from the Azure Portal where it parsed without any issues.
It is complaining about the unrecognised function . To get around this issue we need to use the “concat” string function to treat this as a string literal.
The original syntax is here: “ProductCodes”: “[@{outputs(‘Compose_Product_Detail’)}]”
By surrounding the whole value “[@{outputs(‘Compose_Product_Detail’)}]” with concat as shown below resolves this error.
“@concat(‘[‘, outputs(‘Compose_Product_Detail’)’, ‘]’)”
Breaking the designer when parameterising the subscription Id when calling a function
You may have a call-back function defined in your Logic App which has the subscription guid embedded in the code (blanked out for security reasons) similar to below:
When trying to parameterise the subscription key by simply adding the function “subscription().subscriptionId” in place of the guid value as shown below:
“function”: {
“id”: “/subscriptions/subscription().subscriptionId/resourceGroup…
You will get the following error when trying to same the changes.
To overcome this issue, wrap the value in a concat function as shown below. Note the url has been shorted with “…” to make it readable.
“function”: {
“id”: “[concat(‘/subscriptions/’,subscription().subscriptionId,’/resourceGroups/…/providers/Microsoft.Web/sites/…/functions/Cmn_GuidMapNullValue’)]”
You can also apply this same technique to parameterise other information in the Id key such as the website location.
Enjoy…