I have been developing Microsoft Azure App Service functionality over the last few weeks and have stumbled over many hurdles. The Logic Apps development experience is still definitely in ‘preview’.

One issue that especially concerned me was a problem I had with a Logic App when trying to use a custom API App that had its Access Level set to Internal. This setting lives in All settings => Application settings => Access Level, with the possible options being:

  • Public (anonymous);
  • Internal; or
  • Public (authenticated).

After configuring the Logic App to use the custom API App and running the Logic App, the following error message is shown in the Outputs Link of the Logic App run => Action.

1"status": 403,
2"source": "https://[omitted].azurewebsites.net/api/service/invoke/myinternalaccess.apiapp/DoSomething?api-version=2015-01-14",
3"message": "Permissions for service \"MyInternalAccess.ApiApp\" are set to internal but this request was external."

Clearly, the Logic App was behaving like an external caller of the API App.

The way to fix this is by modifying the code of the Logic App. There were two issues in the code.

Issue 1

In the "parameters" node, there is a parameter for a token for your API App.

 1"parameters": {
 2  "/subscriptions/[...]/resourcegroups/[...]/providers/Microsoft.AppService/apiapps/myinternalaccess.apiapp/token": {
 3    "type": "String",
 4    "metadata": {
 5      "token": {
 6        "name": "/subscriptions/[...]/resourcegroups/[...]/providers/Microsoft.AppService/apiapps/myinternalaccess.apiapp/token"
 7      }
 8    }
 9  },
10...

The code above is missing a "defaultValue" node. In order to fix this issue, add in "defaultValue": "", in after type. The parameter should now look like:

 1"parameters": {
 2  "/subscriptions/[...]/resourcegroups/[...]/providers/Microsoft.AppService/apiapps/myinternalaccess.apiapp/token": {
 3    "type": "String",
 4    "defaultValue": "", 
 5    "metadata": {
 6      "token": {
 7        "name": "/subscriptions/[...]/resourcegroups/[...]/providers/Microsoft.AppService/apiapps/myinternalaccess.apiapp/token"
 8      }
 9    }
10  },
11...

After saving, exiting the code editor, refreshing, jumping up and down for good luck (given that the user experience is not entirely reliable), going back into the editor of the Logic App, waiting a little for things to load (this can be important!), and switching to the code editor, the defaultValue is then magically populated with a nice long set of characters.

Issue 2

The second issue is that the API App action must have an "authentication" node under the "inputs" node.

The API App action that did not work looked like the following:

 1"actions": {
 2  "myinternalaccess.apiapp": {
 3    "type": "ApiApp",
 4    "inputs": {
 5      "apiVersion": "2015-01-14",
 6      "host": {
 7        "id": "/subscriptions/[...]/resourcegroups/[...]/providers/Microsoft.AppService/apiapps/myinternalaccess.apiapp",
 8        "gateway": "https://[omitted].azurewebsites.net"
 9      },
10      "operation": "DoSomething",
11        "parameters": {}
12    },
13    "conditions": []
14  }

The fix is to add the following "authentication" node after the "parameters" node.

1"authentication": {
2  "type": "Raw",
3  "scheme": "Zumo",
4  "parameter": "@parameters('/subscriptions/[...]/resourcegroups/[...]/providers/Microsoft.AppService/apiapps/myinternalaccess.apiapp/token')"
5}

The action should now look like:

 1"actions": {
 2  "myinternalaccess.apiapp": {
 3    "type": "ApiApp",
 4    "inputs": {
 5      "apiVersion": "2015-01-14",
 6      "host": {
 7        "id": "/subscriptions/[...]/resourcegroups/[...]/providers/Microsoft.AppService/apiapps/myinternalaccess.apiapp",
 8        "gateway": "https://[omitted].azurewebsites.net"
 9      },
10      "operation": "DoSomething",
11      "parameters": {},
12      "authentication": {
13        "type": "Raw",
14        "scheme": "Zumo",
15        "parameter": "@parameters('/subscriptions/[...]/resourcegroups/[...]/providers/Microsoft.AppService/apiapps/myinternalaccess.apiapp/token')"
16      }
17    },
18    "conditions": []
19  }

After saving these changes and doing a good-luck dance, the Logic App will now successfully call the API App.

Sometimes, if you go back into the editor, after it has loaded the Discard button is enabled, and if you switch into the code, you may notice that the authentication node is missing. Simply press the Discard button and the authentication node immediately reappears.

Hopefully Microsoft will fix many of the user experience issues with Logic Apps very soon!

Please leave below any comments, feedback or suggestions, or alternatively contact me on a social network.

comments powered by Disqus