com.atlassian.confluence.content.render.xhtml.migration.exceptions.UnknownMacroMigrationException: The macro 'next_previous_links' is unknown.

Migrating Applications to a Different Environment

WSO2 API Manager supports maintaining multiple environments running the same version. This feature allows you to import and export applications between your environments. For example, if you have an application running in the development environment, you can import it and export to the test(QA) environment as shown in the diagram below. Applications do not have to be created from scratch in different environments and you can also choose to skip importing subscription details, as required.

Managing application lifecycle

The lifecycle of an application could be defined as the stages of an application between the development and production environments. The feature facilitates to manage the application life cycle by allowing the user to migrate the applications within desired environments. The user should have admin permissions in order to use this.

Before you begin...

  • Obtain the consumer key/secret key pair by calling the dynamic client registration endpoint
  • Generate the access token using the scope apim:app_import_export  and the preferred grant type.

For instructions, see the Admin REST APIs.

The following sections explain how to export and import applications between environments.

Exporting an application

You can export applications in the API Store and download them as a zipped file. This functionality is secured using OAuth2 Authentication. The example cURL command is given below. The command creates the zipped file in the target folder of your command line.

The zipped file will be as follows:

<exported-Application>.zip
└── <Application-Name>
└── <Application-Name>.json


The REST API for exporting applications is given below.

ParameterDescription
URI

https://<Host:Port>/api/am/admin/v0.12/export/applications

Query parameters

appName=<application-name>
appOwner=<application-owner>

HTTP methodGET
Example

curl -k -H "Authorization: Bearer 9bdb2d36-b044-3783-8654-c597f7ccd90b" "https://localhost:9443/api/am/admin/v0.12/export/applications?appName=sampleApp&appOwner=admin"
It gives a data stream as the output.

To download it as a zipped archive, use the following command:
curl -k -H "Authorization: Bearer 9bdb2d36-b044-3783-8654-c597f7ccd90b"
"https://localhost:9443/api/a m/admin/v0.12/export/applications?appName=sampleApp&appOwner=admin" > exportedApp.zip


Importing an application

You can import an application to your environment as a zipped application. The example cURL command is given below.

You can import applications using the options listed below.

1. Changing the owner of the application
  • The owner of the imported application can be specified by providing a username of a valid user accoring to your preference. The application importer can set the preferred owner’s username to the appOwner parameter. (E.g., appOwner=sampleUser)

  • You can also import the applicatio preserving the application owner information, from the previous environment. The application importer should set the preserveOwner parameter value to true. (E.g., preserverOwner=true). This parameter is set to false by default. An example is shown below.

    curl -k -F "file=@/Desktop/exported_Apps/myExportedApp.zip" -X POST  -H "Authorization: Bearer f6ccabf6-1692-33fe-9275-4c25e5d3a327" https://localhost:9443/api/am/admin/v0.12/import/applications?preserveOwner=true
  • If import the application without specifying any parameters, you will be added as the owner of the application in the imported environment. 
2. Importing the application without subscriptions

You can opt to skip importing the subscriptions of the application. Set the skipSubscriptions parameter to true, and add it as a query parameter. This parameter is set to false by default.

curl -k -F "file=@/Desktop/exported_Apps/myExportedApp.zip" -X POST  -H "Authorization: Bearer f6ccabf6-1692-33fe-9275-4c25e5d3a327" https://localhost:9443/api/am/admin/v0.12/import/applications?skipSubscriptions=true
3. Preserving the application owner

If both appOwnerpreserveOwner parameters are set, then the priority would be given to appOwner over the preserveOwner parameter.

When you import an application as a zipped file, a new application is created within the target environment.

The REST API for exporting applications is given below.

ParameterDescription
URI

https://<Host:Port>/api/am/admin/v0.12/import/applications

Query parameters

appOwner=sampleUser
preserveOwner=<true/false>
addSubscriptions=<true/false>

HTTP methodPOST
Example

curl -k -F "file=@/Desktop/exported_Apps/myExportedApp.zip" -X POST  -H "Authorization: Bearer e1b35f27-eb3b-3c32-9c97-60176c4a25d9" https://localhost:9443/api/am/admin/v0.12/import/applications


curl -k -F curl -k -F "file=@/Desktop/exported_Apps/myExportedApp.zip" -X POST  -H "Authorization: Bearer e1b35f27-eb3b-3c32-9c97-60176c4a25d9" https://localhost:9443/api/am/admin/v0.12/import/applications??appOwner=sampleUser&preserveOwner=false&addSubscriptions=true

Importing applications in a single tenant environment

There are three options to import applications in a single tenant environment.
  • Application A in environment 1 is migrated to environment 2. some APIs may not available in environment 2 (API B in this case) and the the relevant subscriptions are not added in such cases(skipped).

  • A different owner can be specified while importing an application to environment 2,  without preserving the original user of environment 1.

  • The original owner of the application can be preserved when the application is imported to environment 2 by setting the preserveOwner flag to true.

Importing applications in a multi tenant environment

In a situation where an application has API subscriptions in different tenant domains, such subscriptions are added if the relevant APIs with the target tier, are available in the importing environment. Note that the provider of the API may not be the same in the importing environment.

Using the CLI tool to import and export applications

  1. Navigate to the API Management Tooling page.
  2. Click Download under CLI, and download the WSO2 API import/export command line tool based on your OS.
  3. Follow the instructions provided in the README file.  
  4. Start API Manager and issue the relevant commands to import/export and list applications.
com.atlassian.confluence.content.render.xhtml.migration.exceptions.UnknownMacroMigrationException: The macro 'next_previous_links2' is unknown.