How can we automatically update Azure API Management post deployment of Azure Web App?

I am looking for a way to automate below steps using Octopus:

  • Deploy site to an Azure App Service target
  • This app defines its API via OpenAPI, which is consumed by Swagger
  • Import that OpenAPI JSON to your Azure APIM instance, which updates the definitions there with your latest defined by your application

I couldn’t find a way to refresh APIM instance post Azure web app deployment.

Any help would be much appreciated.

Greetings @vichetan! I haven’t played with APIM at all, however, I did some research and it looks like there is an az cli command that can be of assistance - az apim api import.

Add a Run an Azure Script step to your process

Place something similar to the following in the script window

az apim api import -g MyResourceGroup --service-name MyApim --path MyApi --specification-url https://MySpecificationURL --specification-format OpenApiJson

Does this help?

Regards,

Shawn

Hi Shwan,

In your response, you have mentioned “specification-url”. Do we need to pass specific url or can we use existing file from Azure DevOps repository / file from nuget package?

Thanks,
Viral Shah

That was the example from the Microsoft Documentation. --specification-url is an optional parameter. In your case, I think you’d want to use the --specification-path parameter instead to specify a file.

--specification-path
File path specified to import the API.

Hope this helps :slight_smile:

Regards,

Shawn