question

AustinTaylor-4596 avatar image
0 Votes"
AustinTaylor-4596 asked MayankBargali-MSFT commented

The Azure APIM Doesn't Import App Service OpenAPI Spec

I'm trying to get the Azure APIM to import the specs from my OpenAPI document created in Swagger, but when I import my App Service into the APIM, it just populates wildcard operations. My App Service is running a .NET 6 API, and I have used Swashbuckle to build the API documentation.

In both my local and deployed environments, I can navigate to {apiUrl}/swagger/v1/swagger.json and view the Swagger JSON file with the specs, so I know they are being generated properly. If I copy the file into editor.swagger.io I can confirm the file has no errors. I can manually import the JSON file into the API within the OpenAPI Specification editor in the Azure Portal and that will import my specifications properly.

I am not sure why the APIM is unable to automatically import the specification and continues to use wildcard operations when I attempt to import it. If I have to continue manually pasting in the JSON file, I guess it's not the end of the world. It just seems like an unnecessary pain after taking the time to properly set up my project to use the OpenAPI specification.

I also notice if I try to connect to an API in the APIM from the App Service, I get the following error, "Please provide OpenAPI specification for the App."
263384-image.png


Any help with this would be very appreciated!

azure-webappsazure-api-managementdotnet-aspnet-core-webapiazure-openai
image.png (106.9 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

MayankBargali-MSFT avatar image
0 Votes"
MayankBargali-MSFT answered MayankBargali-MSFT commented

@AustinTaylor-4596 Thanks for reaching out. It looks like the configuration issue that the API Definition was not configured correctly at the App Service end.

To configure API Definition/Spec in App Service:

  • Navigate to App Service Resource

  • Click on "API definition

  • Provide the Url of the API Definition (must be publicly accessible)

  • Save

264087-image.png

After you perform the above steps, please try to import the App Service resource, APIM will use the API spec that has been configured.

Feel free to get me if you need any assistance.


image.png (88.3 KiB)
· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@MayanBargali-MSFT, that seems to do the trick! I have a question, moving forward, when I make and publish changes to my App Service, will those be automatically synced with the APIM since they are now linked?

0 Votes 0 ·

@AustinTaylor-4596 No it will not be automatic changes. You need to manually add the new changes to the APIM.

0 Votes 0 ·

If the APIM automatically updates now, what happens if I update a policy on an API endpoint, then I make a change to the API endpoint in my App Service?

0 Votes 0 ·
dragonbe avatar image
0 Votes"
dragonbe answered AustinTaylor-4596 commented

Hi @AustinTailor-4596,


When you create a new API in the APIM blade, you should have the opportunity to select the URL or a local file and providing additional details of the specification. Have you tried uploading the swagger.json manually instead of using a published URL?

263941-screenshot-2022-11-24-at-120713.png



· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thanks for your reply @dragonbe, I am able to add the specification manually, but I would prefer it to automatically be added when connecting to the App Service. I just don't understand why I get the error when I believe my specification is being generated properly.

0 Votes 0 ·