Get/generate swagger url of Azure APIm API - azure

I have setup apis in Azure APIm and individual actions are working by their respective url.
I want a Swagger uri of this API which is having azure domain and lists all the actions in it.
For example, by default APIm provides a sample api named "Echo API" whose url becomes: https://testresource.azure-api.net/echo
Now, I understand that there is an option on the API context menu to export it in Swagger format.
But what I am looking for is such a url that render this specifications online:
https://testresource.azure-api.net/echo/swagger
Similar question here have an answer to add an endpoint for swagger/ui/index. Which I believe is having an endpoint in native api and configure as an action. Is there any way APIm generate/provide such a url for already setup APIs?

Thank you MayankBargali-MSFT and Sam Cogan Posting your suggestion as answer to help other community members.
You need to use the Create/Update API to pass in the URL of your swagger file. You can find an example
here.
Unfortunately, API only accepts it as the swagger file while importing the swagger file as documented in the request
body.
You can try uploading your swagger file to your storage account or any
path which is publicly accessible.
Reference: https://learn.microsoft.com/en-us/answers/questions/687043/import-swagger-file-programatically-to-azure-apim.html.

Related

In Azure Cognitive Services Text Translation what is the endpoint `https://<resource name>.cognitiveservices.azure.com/sts/v1.0/issuetoken` for?

Want to try out the Text Translation API from , I created my text translation resource, as described at https://www.microsoft.com/en-us/translator/business/trial/#get-started, and was presented with a subscription key and an endpoint https://<resource name>.cognitiveservices.azure.com/sts/v1.0/issuetoken.
I proceeded to replicate the sample code from https://learn.microsoft.com/en-us/azure/cognitive-services/translator/quickstart-translate?pivots=programming-language-csharp (also on Github).
That code wants the subscription key and endpoint added as environment variables, and I did so, using the strings provided to me when creating the resource. However, trying to run the sample code it fails with a 404 when going to the endpoint. Looking more carefully at https://learn.microsoft.com/en-us/azure/cognitive-services/translator/quickstart-translate?pivots=programming-language-csharp, I noticed that it told me to use https://api.cognitive.microsofttranslator.com/ as endpoint, not the URL above. After that change, the code worked.
So what is the https://<resource name>.cognitiveservices.azure.com/sts/v1.0/issuetoken endpoint for? Certainly one gets the impression it's the endpoint to use for translation requests, so maybe clarify the documentation there?

Swashbuckle generated Swagger creates duplicate version path in Azure API Management

I am trying to configure Azure API Management to use versioning and have it work with a Swagger / Open API document generated by Swashbuckle.
I have an API with 2 versions - 1.0 and 2.0. I have configured Swashbuckle to generate 2 seperate Swagger documents, one for each version. All good.
The versioning scheme is by path so consumers need to call the correct path (v1.0 or v2.0). Like so: https://someurl/v1.0/some/thing
I have defined both versions in Azure API Management and imported both documents.
The problem is that Azure API Management is adding the path to the base URL and then because the path that is defined in the Swashbuckle generated Open API document I'm ending up with https://someurl/v1.0/v1.0/some/thing in Azure API Management.
Below is a snippet of the generated Swagger / Open API...
And the API version settings in Azure API Management...
And the full URL in Azure API Management...
So, my questions is how can I generate a Swagger document, using Swashbuckle or any other tool in a way that I can support Azure API Management versioning using the path versioning scheme.
Thank you in advance!
Since OpenAPI specification itself does not allow you to define versioning scheme, it is impossible to infer user intention at APIM level. One may want to import API with /v1.0/ in path as a single API, someone else, like in your case, wants to have API + version set. APIM by default does not create/update version sets during API import, so the only way at the moment is to remove /v1.0 prefixes from OpenAPI spec before you import into APIM.
APIMs domain model allows one to control versioning scheme (path prefix, header name/value, query parameter name/value) at the level of API version set, so that you do not need to duplicate /v1.0 on every operation of your API. By nature of this if your API version set is configured to have path prefix of /v1.0 it will be appended to all API paths included into this version set. And that is what produces the doubling.

Missing urlTemplateRewrite field in REST API of Create Operation in Azure API Management Service

I am trying to use Azure API Management Service using REST API. I want to create / update API Operations using REST API. I referred to Create New Operation documentation and found that property for "Rewrite URL Template" field.
I want to create / update a new Operation which has name, method, urlTemplate, urlTemplateRewrite and description properties.
Can someone suggest on how urlTemplateRewrite property can be populated using REST API?
Please refer to discussion here: https://social.msdn.microsoft.com/Forums/azure/en-US/b2dae2eb-27d8-46cb-bf0f-571ef1f44efe/unable-to-create-new-api-operations-using-rest-api-missing-urltemplaterewrite-field-in-rest-api?forum=azureapimgmt

How do I add behaviour to my Azure API (e.g. connect it to my back-end)?

I created an API in Azure portal, and it has a "product", whatever that means... Now how do I connect it to a back-end to add functionality?
I've seen many videos and tutorials (Channel 9 and others), and they all explain how to manage the API and so on.
I couldn't find any tutorial/explanation how to add actual functionality, so I suspect that I may not grasp this whole subject correctly...
You connect your own API to the Azure API in the "add API" dialog in Azure.
See http://azure.microsoft.com/en-us/documentation/articles/api-management-get-started/
=> Create an API
There is an input field "Web service URL". This is the url to your real api.
Azure API is only a wrapper which adds additional functionality to your API.

Azure REST API on a web role does not accept POST with Json body

We are using Open Rasta on an Azure Web Role to provide a REST API. Our GET methods work fine returning Json data. When I try and POST a request with a Json body I get this error.
The server cannot service the request because the media type is unsupported. It returns a 415 code. I examined the messages in Fiddler and they look ok.
I am guessing that IIS is not setup to allow -> Content-Type: application/json
I found this http://msdn.microsoft.com/en-us/library/gg433059.aspx but am not sure what I need to do to get this to work.
Any help would be great.
I dont recall the answer exactly, but in Non Azure types of situations at least there is a web.config file that you set to allow Posts.
I believe it's this:
system.web
protocols
add name = "HttpPost"

Resources