Back to List

Azure Tips & Tricks: Moving Operations in API Management

Todd Taylor Todd Taylor  |  
May 07, 2019

Azure API Management (APIM) helps developers save a lot of time by doing most of the heavy lifting involved in creating an API gateway and developer portal. However, the APIM administrative UI is missing a few minor times-saving features, such as the ability to move API operations between APIs.

For example, assume you've been asked to move the Create Contact, Delete Contact, and Modify Contact operations from the Contacts API to the Users API as shown below:


How much time should you estimate for this task? It shouldn't take more than a few minutes, right?

You'll quickly find there is no "Move API Operation" functionality in the Azure admin interface. This means you'll be recreating each operation from scratch - which is time consuming, error prone, and boring work! This might not seem so bad if you only need to move a few operations, but it gets incrementally more painful as the number grows.

To reduce the pain of manually recreating operations in an attempt to move them, Microsoft provides the Azure RM API Management PowerShell library to enable automation for most of the work.

The PowerShell Solution


One Step at a Time

The process I followed for moving operations between APIs is as follows:

  1. [Manual Step] Save a copy of the current APIM configuration to it's built-in repository. If something goes wrong, you can use this back-up to get your original configuration (which goes beyond the scope of this blog post).
  2. [PowerShell] Authenticate with Azure using the PowerShell Add-AzureAccount function. See see this article from Redmond Magazine for more details.
  3. [PowerShell] Create a copy of each API operation and operation policy in the new API.
  4. [Manual Step] Verify that all operations were copied successfully.
  5. [PowerShell] Remove the old API operations and operation policies from their original API location.

While Step 4 could be eliminated, I opted not to because I found out the hard way that the operation's description cannot exceed 1,000 characters when using PowerShell. Because the description in many of my projects' operations exceeded 1,000 characters and I wasn't the developer that added the descriptions, I kept the original operations available so I could manually copy/paste the description text into the new operations.


PowerShell Script: Copying Operations & Policies

GitHub CopyOperations.ps1

While there is no PowerShell "move operation" function, the CopyOperations.ps1 script makes use of the following PowerShell functions to create a copy of each operation in the desired location:

In addition to copying the operations, the policies within each operation must also be copied. Policies are found within the Inbound and Outbound processing sections of the Azure admin portal when editing an operation.

api interface policies

The CopyOperations.ps1 script copies each policy using the following PowerShell functions:


PowerShell Script: Remove Old Policies

GitHub RemoveOperations.ps1

Once each operation has been copied to its new location and you have verified everything is correct, the RemoveOperations.ps1 script can be run to remove the operations from the old API location. The script uses the following function:


PowerShell Script Variables

At the head of the PowerShell scripts are several variables that must be modified to suit your environment. The $apimServiceName and $apimResourceGroupName values are shown below:

api interface variables

The values for the $apiNameFrom and $apiNameTo variables are found on the Settings tab of each API:

api interface api name

The $operationNamesToMove is a collection of strings consisting of operation names. Each operation name is found by editing the operation within an API (i.e., click the pencil icon in the Frontend section to edit the Frontend):

api interface operation name


PowerShell was my weapon-of-choice for solving the problem of moving operations between APIs. However, the Azure API Management REST APIs could also be used to accomplish the same tasks.

If you have any questions regarding the provided scripts or found them useful, please leave a message in the comments below. If you would like information on how Azure API Management can help you or your business, let's talk about your goals.



Love our Blogs?

Sign up to get notified of new Skyline posts.


Related Content

Blog Article
Machine Monitoring IoT Solution with Azure Services and Power BI
Eric SaltzmannEric Saltzmann  |  
Jun 11, 2019
We often hear organizations ask how they can drive more insights out of their connected devices. Though the Internet of Things (IoT) has been a buzzword for the last few years, many organizations are still struggling through the headache of implementing an IoT pilot or solution. Most of the...
Blog Article
Azure Tips & Tricks: Application Insights Snapshot Debugger
Todd TaylorTodd Taylor  |  
May 21, 2019
A painful memory that is burned into my developer-brain is a production support issue for a .NET web API that I wrote years ago. I worked for a large retailer at the time, and the bug was preventing electronic pricing signs from displaying the most up-to-date price for hundreds of products at...
Blog Article
How to Implement a Cloud-based Business Continuity Plan
Skyline Technologies  |  
Apr 23, 2019
First and foremost, you need to clarify your definitions. Make sure your team, your IT team, your business leaders, and your organization understand the definitions of RPO and RTO. Also make sure they understand how those impact their business and their business continuity plan.   Case...
Blog Article
Advantages of a Cloud-based Business Continuity Plan
Skyline Technologies  |  
Apr 09, 2019
One of the concerns we hear from customers is how much control is given up when moving to the cloud – especially in business continuity. That’s understandable, so we’re going to break down the advantages of an Azure Cloud Cold Site and Hot Site.   Azure Cloud Cold Site...
Blog Article
5 Pitfalls of a Traditional Business Continuity Plan
Skyline Technologies  |  
Mar 26, 2019
To get a clear view of where the cloud fits into your business continuity plan, it's helpful to examine the pitfalls of a traditional plan.   1. Cost Business continuity can be extremely costly when taking the traditional approach. You're buying two of everything for production...