Migrate apps from Qlik Sense Enterprise client managed to Qlik Cloud
Overview
In this tutorial, you are going to learn how to migrate an application from a Qlik Sense client-managed server to a Qlik Cloud tenant using qlik-cli.
Requirements
- qlik-cli version 1.5.0 or higher
- A licensed Qlik Sense client-managed instance with JWT virtual proxy configured
- A licensed Qlik Cloud tenant, and a user with either Developer or TenantAdmin role assigned.
- Basic knowledge of jq using bash or working with JSON in powershell.
Create contexts for accessing Qlik Sense instances
A context in qlik-cli is a configuration for connecting to a Qlik Sense instance. Contexts store the URL to connect to a server, and the API key to authenticate to the server.
Configure Qlik Sense client-managed context
Configure the context for the client-managed server following the directions in the Using Qlik Sense client-managed Repository API with qlik-cli tutorial.
Configure Qlik Cloud context
To create a context for Qlik Cloud, follow the create a new context tutorial.
Export an app from client-managed
Export an app from client-managed using qlik-cli with the following command. Start by setting the qlik-cli context to the client-managed server.
qlik context use <ClientManagedContextName>
qlik-cli commands for client-managed always begin with qlik qrs
then
the command. You can view a list of available commands by entering
qlik qrs --help
. Now, obtain a list of apps from the server with the
qlik qrs app ls
command.
##This command will return a list of names and guids for the apps on the server.
qlik qrs app ls --insecure | jq -r '.[] | {"name":.name,"id":.id}'
##returns a list of applications and GUIDs like this
{
"name": "ConsumerSales",
"id": "931d847e-b36a-4511-9547-6cc0f46b1b9c"
}
{
"name": "foo",
"id": "14f34e64-e0ed-47d9-a5ff-5f51b30a2a73"
}
Note qlik-cli commands sent to client-managed servers may need to include the --insecure switch to bypass untrusted and self-signed certificate blocking.
Observe the app "id" you want to export and enter the export command into the terminal.
##Supply the appId, filepath and filename as parameters
WinAppId="<App id (GUID) from client-managed>"
filepath="<File path to the destination of the exported app>"
filename="<File name with .qvf extension for the file to place in the filepath>"
##This command will export an app to a qvf file at the specified location
qlik qrs app export create $WinAppId --skipdata true --insecure --output-file $filepath/$filename
Note The export command doesn't include private content from apps published to a stream that contributors may have added but haven't shared with others. To export and reassign private content, review the object migration tutorial. All base sheets and community (public) sheets are part of the qvf file, but they are now private.
Import the app into Qlik Cloud
To import the app into a Qlik Cloud tenant, change the qlik-cli context to the entry you created for Qlik Cloud and use the import command.
##Set the context to the Qlik Cloud instance of Qlik Sense
qlik context use <CloudContextName>
##specify an app name for the imported app
appname="<Name of the app to show once imported>"
filepath="<File path to the destination of the exported app>"
filename="<File name for the file to place in the filepath>"
##Issue the command so it returns the GUID for the app in Qlik Cloud to a variable or stdOut for future use.
SaasAppId=$(qlik app import --file $filepath/$filename --mode new --name $appname -q)
The app appears in the personal space of the user whose API key is entered into the qlik-cli context.
Make private sheets public
Publish the private sheets (aka My sheets
) to public by getting a list of sheets
in the app, looping over them and executing qlik app object publish
.
##Obtain a list of sheets in an app where ${appId} is the GUID for the app, also
##known as the resource ID in Qlik Cloud.
sheets=$(qlik app object ls --app ${SaasAppId} --json | jq '.[] | select(.qType=="sheet")')
##Loop through the sheets to promote them to public app objects
for row in $(echo "${sheets}" | jq -r '.qId'); do
qlik app object publish ${row} -a ${SaasAppId}
done
Place the app in a shared space
Assign the app to a space using the qlik app space update
command. In
this example, you know the name of the space to assign the app to, but you don't
know the space ID, which is required for assignment.
##Given a name of a space as an input parameter, return the space ID and assign
##an app to the space.
spacename="${1}"
spaceId=$(qlik space filter --names $spacename -q)
qlik app space update ${SaasAppId} --spaceId ${spaceId} --verbose
Change the owner of the app
Changing the owner of an application requires knowing the app ID as well as the
owner ID for the new owner. Unlike app ID, which is a GUID, the owner ID is a
unique alphanumeric character string. To return the ID of the user when the
email is known, use qlik user ls --email
and parse the response.
##Obtain the user ID for the new owner of the app using email address as a filter.
userEmail=$1
newOwnerId=$(qlik user ls --email ${userEmail} | jq -r '.[].id')
##Set the new user as the owner of the application
qlik app owner $SaasAppId --ownerId $newOwnerId
Sample code
#!/bin/bash
##Specify the path and file name to use for exporting the app from Qlik Sense client-managed
filepath="<File path to the destination of the exported app>"
filename="<File name with .qvf extension for the file to place in the filepath>"
##Set the qlik-cli context to the client-managed server
qlik context use <ClientManagedContextName>
##Obtain a list of app names and GUIDs from the Qlik Sense on client-managed server
qlik qrs app ls --insecure | jq -r '.[] | {"name":.name,"id":.id}'
##Identify the GUID to migrate from client-managed to Qlik Cloud and enter it here
WinAppId="<App id (GUID) from Qlik Sense client-managed>"
##Export the app from Qlik Sense client-managed
qlik qrs app export create $WinAppId --skipdata --insecure --output-file $filepath/$filename
##Specify the name the app will use in Qlik Cloud
appname="<Name of the app to show once imported>"
##Set the context to the Qlik Cloud instance of Qlik Sense
qlik context use <SaaSContextName>
##Import the app to Qlik Cloud and return the new GUID for the app
SaasAppId=$(qlik app import --file $filepath/$filename --mode new --name $appname -q)
##Obtain a list of sheets in the app, then loop through and set them to public
sheets=$(qlik app object ls --app ${SaasAppId} --json | jq '.[] | select(.qType=="sheet")')
for row in $(echo "${sheets}" | jq -r '.qId'); do
qlik app object publish ${row} -a ${SaasAppId}
done
##Supply the name of the space to assign the app to, and assign the app to the space
spacename="<Name of the space to assign the app to>"
spaceId=$(qlik space filter --names $spacename -q)
qlik app space update ${SaasAppId} --spaceId ${spaceId} --verbose
##Change the owner of the app using the provided email address
##Obtain the user ID for the new owner of the app using email address as a filter.
userEmail="<email address of the new owner>"
newOwnerId=$(qlik user ls --email ${userEmail} | jq -r '.[].id')
##Set the new user as the owner of the application
qlik app owner $SaasAppId --ownerId $newOwnerId
#!/user/bin/pwrsh
##Specify the path and file name to use for exporting the app from Qlik Sense client-managed
$filepath="<File path to the destination of the exported app>"
$filename="<File name with .qvf extension for the file to place in the filepath>"
##Set the qlik-cli context to the client-managed server
qlik context use <ClientManagedContextName>
##Obtain a list of app names and GUIDs from the Qlik Sense client-managed server
qlik qrs app ls --insecure --raw | ConvertFrom-Json | Select-Object -Property name, id
##Identify the GUID to migrate from client-managed to Qlik Cloud and enter it here
$WinAppId="<App id (GUID) from Qlik Sense on client-managed>"
##Export the app from Qlik Sense client-managed
qlik qrs app export create $WinAppId --skipdata --insecure --output-file $filepath/$filename
##Specify the name the app will use in Qlik Cloud
$appname="<Name of the app to show once imported>"
##Set the context to the Qlik Cloud instance of Qlik Sense
qlik context use <SaaSContextName>
##Import the app to Qlik Cloud and return the new GUID for the app
$SaaSAppId=qlik app import --file $filepath/$filename --mode new --name $appname -q
##Obtain a list of sheets in the app, then loop through and set them to public
$sheets=qlik app object ls --app $SaasAppId.resourceId --json | ConvertFrom-Json | Where-Object qType -eq "sheet"
$sheets | foreach-object {qlik app object publish $_.qId -a $SaasAppId.resourceId}
##Supply the name of the space to assign the app to, and assign the app to the space
$spacename="<Name of the space to assign the app to>"
$space=qlik space filter --names $spacename -q
qlik app space update $SaasAppId.resourceId --spaceId $space.id
##Change the owner of the app using the provided email address
##Obtain the user ID for the new owner of the app using email address as a filter.
$userEmail="<email address of the new owner>"
$newOwnerId=qlik user ls --email $userEmail | ConvertFrom-Json | select id
##Set the new user as the owner of the application
qlik app owner $SaasAppId.resourceId --ownerId $newOwnerId.id