Today I was running into this Failed to fetch swagger issue while publishing API Apps using Visual Studio and therefore decided to devote a blog post to it. Hopefully this post will save some others some time.
Failed to fetch swagger – Configuration
When testing API Apps, I typically use the Publish web option instead of the preferred way of working with Azure Resource Manager templates. Due to this I often forget to configure the API Definition and CORS settings for the Web App containing my API App. This results in the following error message:
Error: Failed to fetch swagger. Ensure you have CORS enabled on the endpoint and are calling an HTTPS endpoint.
Fortunately, it’s really easy to fix this issue manually by following the steps below:
- Step 1: Locate the Web App hosting your API App within the Azure Management Portal.
- Step 2: Click on settings, and within the Settings blade locate the section called API.
- Step 3: For the API Definition, make sure to provide the link as configured within your API App. The default is
- Step 4: Open the CORS options and add
*, which is required for the Logic Apps designer to work properly
- Step 5: Restart the Web App
Custom API Apps – https://azure.microsoft.com/en-us/documentation/articles/app-service-logic-custom-hosted-api/