0
votes

Is there a way to move an operation defined in Azure APIM to a different API than it was originally defined in? I'd like to reorganize some operations into new APIs w/o having to manually recreate the operation in the desired location. (Note that the APIs have not been published to production as of yet, so this won't be a breaking change.) I don't see any way to accomplish this via the APIM UI and haven't had much luck at finding a programmatic way to do this.

For example using the image below, how would I move the POST Add a Customer Address operation from the Customer Management API to the Prospect Customer API?

enter image description here

1
At present,from the Azure portal this can't be achieved. But yes as you have rightly mention you can manually recreate the operation at desired location.DixitArora-MSFT

1 Answers

3
votes

While not a perfect solution, the Azure RM API Management PowerShell library helped me to build a PowerShell script that gets me most of what I wanted, but still requires a little manual labor.

In PowerShell, I created an array of operation IDs that I want to move, then used a combination of the following functions in a for-each loop to 'move' the operations to the desired API:

  • Get-AzureRmApiManagementOperation - Used to read the existing operation.
  • New-AzureRmApiManagementOperation - Used to create a new operation based on the existing one created by mapping the results of the Get function to this New function. Note that there is a 1000 character limit on the Description field.
  • Remove-AzureRmApiManagementOperation - Used to remove the operation from the old API location. I don't recommend using this unless you are darn sure the previous steps worked exactly as you want. Because I ran into an issue where the operation description field can only be 1000 characters or less, I'm glad I didn't delete the operation from the old location because I had to manually copy/paste the description into the new location.

While the above functions will help in copying the operations, the policies within each operation won't be copied. Therefore, the following functions can be used to ensure the policies are copied as well: