Accessing v1 APIs and BizTalk APIs from Logic Apps
There are a lot of great things about the new Logic Apps Preview Refresh, but one of the questions that comes up is "How do I still access v1 API Apps or API Apps that aren't yet managed APIs?" You can still access these APIs and use their functionality in a Logic App, and we are releasing features quickly to help make this easier (like listing those in your resource group). For a full list of API Apps v1 that are in the marketplace, see the document here.
For a version of this article that includes screenshots, you can check out @probertdaniel's post here.
Setup
After you have deployed an API v1 App from either the Marketplace, a deployment script, or Visual Studio, you need to set a few properties for things to work nicely.
API Permission
When you open the API app in your resource group, you can click "Settings" and "Application Settings" to see a list of permissions for the API App. You need your API App Host (the actual website where the logic occurs) to be accessible to Logic Apps, which means you need to set this to Public (anonymous). This is just the permission settings for the API App v1 container. You can still use Active Directory authentication to secure the API from any requests over the internet. For instructions on how to enable that on the API App host, see this article.
The rest of these settings take place on the API App Host (listed in your essentials as a link under either "Host" or "API App Host")
CORS
When the Logic Apps designer makes a request to get the swagger document, the request is coming from your browser which will be a different origin than where the API App resides (azurewebsites.net). You need to make sure you have CORS enabled. To do this on your API App Host, click "Settings" and under the "API" section you will see "CORS". I recommend just setting this to a wildcard *, but you can use F12 or Fiddler to see what the origin of your request to get Swagger is from the designer. For most people right now this will likely be 'https://ema1.exp.azure.com'
API Definition
In order for the API to show up under the "Show APIs in my Resource Group" (coming very soon), make sure you set the API Definition to the URL of the swagger. For BizTalk APIs this value is usually:
https://{apiHostName}.azurewebsites.net/swagger/docs/1.0
For most custom APIs using swashbuckler this url is:
https://{name}.azurewebsites.net/swagger/docs/v1
For any BizTalk API though you can go through the management plane to get the Swagger document. It follows this pattern:
https://management.azure.com/subscriptions/{subscriptionId}/resourcegroups/{resourceGroup}/providers/Microsoft.AppService/apiapps/{apiAppName - like jsonencoder}/apidefinitions/swagger-2.0-standard?api-version=2015-03-01-preview
These are the same URLs that should work with the HTTP + Swagger action
Using in Logic Apps
You can now use these APIs within Logic Apps. By the time you read this we may have the 'list sites in my resource group' feature live, but even if not, you can add the HTTP + Swagger action and point it to the swagger URL. It will parse the swagger, and present you with the parameters to begin using.
Notes
JSON Encoder and BizTalk Rules /docs/v1 URL currently will not work. You need to go through the management.azure.com point listed above. We are working to fix it so it should work for new apps deployed shortly.
Comments
Anonymous
February 26, 2016
I wish I had read the Notes section before spending couple hours to figure out why my BizTalk Rules /docs/v1 URL was not working.... :-)- Anonymous
March 17, 2016
JSON Encoder works now.
- Anonymous