Migrate Apps from Qlik Sense on Windows to Qlik Sense SaaS

Overview

In this tutorial, you are going to learn how to migrate an application from a Qlik Sense on Windows server to a Qlik Sense Enterprise SaaS tenant using qlik-cli.

Requirements

Sections

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 on Windows context

Configure the context for the Qlik Sense on Windows server following the directions in the Using Qlik Sense on Windows Repository API with qlik-cli . Here's the snippet for creating the context.

##qlik context create <contextName> --server <serverUrl> --server-type windows --api-key <JWTToken>
##For the <serverUrl> make sure to include the virtual proxy prefix to point qlik-cli to the configured entry point

qlik context create QSEoW --server https://192.168.254.243/jwt --server-type windows --api-key eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyaWQiOiJoYXJyeSIsInVzZXJkaXJlY3RvcnkiOiJxc2VmdyIsIm5hbWUiOiJIYXJkY29yZSBIYXJyeSIsImVtYWlsIjoiaGFycnlAZXhhbXBsZS5jb20iLCJncm91cHMiOlsiQWRtaW5zdHJhdG9ycyIsIlNhbGVzIiwiTWFya2V0aW5nIl0sImlhdCI6MTYwMzgxOTYyOSwiZXhwIjoxNjM1MzU1NjI5LCJhdWQiOiIxMTJhZGFtcyJ9.gDWFqJ8fZbo9QpF52CnlhKCMsHal2AcobIVwhVCpnbLfpmc-Z_k4uUWGh2TxaSucjQ5-k5I9s9sNgIPskqaVQN2JanFXxIJKRFow9LbuSbImZs74RsQ6TqsoJTu7_5eKLv2VRAqoh6Tqabl5vma1JdhHbsTKGixt8yGZI7Q2QNjObQq8hAh6VveNWcUVkB60LEMOPiipij7VTKQ7IQg-rG4XA8xgYxbOb6i3Q6miY4kGSGujbsjtYLevEJQlEZtij2JMMDeH_nwH2MWhWhOBL1TpAAUKkCOxPFDjGacxGvkObAOFjL-Ztx0LdVwF2BXxVerQ1xKyl0YpLErS4d576Q

To use the context after configuring it, enter qlik context use <contextName>

Configure Qlik Sense SaaS

The procedure for creating the context for Qlik Sense Saas is almost identical to the Windows configuration. Use the URL for the cloud instance and the API key created from following the API key tutorial.

##qlik context create <contextName> --server <serverUrl> --server-type cloud --api-key <ApiKey>

qlik context create QSESaaS --server https://example.us.qlikcloud.com --server-type cloud --api-key eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyaWQiOiJoYXJyeSIsInVzZXJkaXJlY3RvcnkiOiJxc2VmdyIsIm5hbWUiOiJIYXJkY29yZSBIYXJyeSIsImVtYWlsIjoiaGFycnlAZXhhbXBsZS5jb20iLCJncm91cHMiOlsiQWRtaW5zdHJhdG9ycyIsIlNhbGVzIiwiTWFya2V0aW5nIl0sImlhdCI6MTYwMzgxOTYyOSwiZXhwIjoxNjM1MzU1NjI5LCJhdWQiOiIxMTJhZGFtcyJ9.gDWFqJ8fZbo9QpF52CnlhKCMsHal2AcobIVwhVCpnbLfpmc-Z_k4uUWGh2TxaSucjQ5-k5I9s9sNgIPskqaVQN2JanFXxIJKRFow9LbuSbImZs74RsQ6TqsoJTu7_5eKLv2VRAqoh6Tqabl5vma1JdhHbsTKGixt8yGZI7Q2QNjObQq8hAh6VveNWcUVkB60LEMOPiipij7VTKQ7IQg-rG4XA8xgYxbOb6i3Q6miY4kGSGujbsjtYLevEJQlEZtij2JMMDeH_nwH2MWhWhOBL1TpAAUKkCOxPFDjGacxGvkObAOFjL-Ztx0LdVwF2BXxVerQ1xKyl0YpLErS4d576Q

To use the context after configuring it, enter qlik context use <contextName>

Export an app from Windows

Export an app from Qlik Sense on Windows using qlik-cli with the following command. Start by setting the qlik-cli context to the Windows server.

qlik context use <windowsContextName>

qlik-cli commands for Qlik Sense on Windows 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 windows server 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 Qlik Sense on Windows>"
filepath="<File path to the destination of the exported app>"
filename="<File name 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.qvf

Note The export command doesn't include private sheets from apps published to a stream that contributors may add but haven't shared with others. All base sheets and community (public) sheets are part of the qvf file, but they are now private.

Import the app into SaaS

To import the app into a Qlik Sense SaaS instance, change the qlik-cli context to the entry you created for SaaS and use the import command.

##Set the context to the SaaS instance of Qlik Sense
qlik context use <SaaSContextName>

##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 SaaS to a variable or stdOut for future use.
SaasAppId=$(qlik app import --file $filepath/$filename.qvf --mode new --name $appname | jq -r '.resourceId')

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 Sense SaaS.

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

Update the space an app is part of 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 ls | jq -r --arg spacename ${spacename} '.[] | {id:.id,name:.name} | select(.name==$spacename) | .id')
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 on Windows
filepath="<File path to the destination of the exported app>"
filename="<File name for the file to place in the filepath>"

##Set the qlik-cli context to the windows server
qlik context use <windowsContextName>

##Obtain a list of app names and GUIDs from the Qlik Sense on Windows server
qlik qrs app ls --insecure | jq -r '.[] | {"name":.name,"id":.id}'

##Identify the GUID to migrate from Windows to SaaS and enter it here
WinAppId="<App id (GUID) from Qlik Sense on Windows>"

##Export the app from Qlik Sense on Windows
qlik qrs app export create $WinAppId --skipdata true --insecure --output-file $filepath/$filename

##Specify the name the app will use in SaaS
appname="<Name of the app to show once imported>"

##Set the context to the SaaS instance of Qlik Sense
qlik context use <SaaSContextName>

##Import the app to SaaS and return the new GUID for the app
SaasAppId=$(qlik app import --file $filepath/$filename --mode new --name $appname | jq -r '.resourceId')

##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 assing the app to the space
spacename="<Name of the space to assign the app to>"
spaceId=$(qlik space ls | jq -r --arg spacename ${spacename} '.[] | {id:.id,name:.name} | select(.name==$spacename) | .id')
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 on Windows
$filepath="<File path to the destination of the exported app>"
$filename="<File name for the file to place in the filepath>"

##Set the qlik-cli context to the windows server
qlik context use <windowsContextName>

##Obtain a list of app names and GUIDs from the Qlik Sense on Windows server
qlik qrs app ls --insecure --raw | ConvertFrom-Json | Select-Object -Property name, id

##Identify the GUID to migrate from Windows to SaaS and enter it here
$WinAppId="<App id (GUID) from Qlik Sense on Windows>"

##Export the app from Qlik Sense on Windows
qlik qrs app export create $WinAppId --skipdata true --insecure --output-file $filepath/$filename

##Specify the name the app will use in SaaS
$appname="<Name of the app to show once imported>"

##Set the context to the SaaS instance of Qlik Sense
qlik context use <SaaSContextName>

##Import the app to SaaS and return the new GUID for the app
$SaaSAppId=qlik app import --file $filepath/$filename --mode new --name $appname | ConvertFrom-Json |  Select-Object -Property resourceId

##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 assing the app to the space
$spacename="<Name of the space to assign the app to>"
$space=qlik space ls | ConvertFrom-Json | Where-Object {$_.name -eq $spacename} | select id
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
Was this page helpful?