Add a user to a tenant with Platform Operations
Add user to a tenant
Tenants provisioned in Qlik Cloud programmatically are deployed without any user accounts. This guide shows you how to copy a user from one tenant to another.
For more information on how to achieve this via Qlik APIs and toolkits, review the pro-code Add user to a tenant tutorial.
Requirements
- A Qlik Cloud tenant with access to Qlik Application Automation.
- Valid OAuth client with access to the tenants on which you wish to run the automation.
- Access to a source tenant with existing users.
- Access to a target tenant.
Variables you need to complete this tutorial
sourceTenant
: The hostname for your source Qlik Cloud tenant (for example platformoperations.eu.qlikcloud.com).targetTenant
: The hostname for your target Qlik Cloud tenant (for example targettenant.eu.qlikcloud.com).userEmail
: The email of the user that you wish to move to the new tenant.
Configuration
Drag a Get Tenant Name And Region block onto your Start block. This should
be configured with the Hostname set to sourceTenant
.
Add a List Users block, and set the Tenant to
the Get Tenant Name And Region block, and the Filter to match the
format email eq "myname@qlik.com"
, substituting the email with your userEmail
.
This will retrieve any users on the tenant who have that email address, allowing
you to copy their attributes to the target tenant.
Add another Get Tenant Name And Region block, this time setting the Hostname
to the targetTenant
.
Add a List Roles block, specifying the second Get Tenant Name And Region block
to load these roles from the targetTenant
, and entering a filter to return only
the role for TenantAdmin with name eq "TenantAdmin"
.
Add a Transform List block, using the List Roles block as input, and add a single field in the output list, ID. This field should map to the ID field in the input list. This will clean up the output from the List Roles block so that it can be directly passed back into Qlik Cloud when creating a new user.
Add a Create User block, specifying the targetTenant
as the Tenant using the
corresponding Get Tenant Name And Region block. Configure the other Inputs
(Name, Email, and Subject) on the block to match the user returned from
the List Users block run against the sourceTenant
. Use the output from the
Transform List block as the input for AssignedRoles.
Add an Output block to return the newly created user.
Select Run to trigger the automation. The output will return the user metadata
for the user on the targetTenant
. That user will now be immediately able to
sign in, if the tenant is using Qlik Account as the Identity Provider.
If you wish to use a custom Identity Provider, then you can use a similar process as for these Qlik Account users, but you will need to pre-provision the Identity Provider to the tenant, which is beyond the scope of this tutorial.
Full automation snippet
Full automation snippet
To import this snippet to your own automation, either:
- Save as a JSON file, right click the canvas in an automation, and select Upload workspace.
- Copy the snippet to the clipboard, right click the canvas in an automation, and select Paste blocks.
{"blocks":[{"id":"2CDF95F3-AEE2-4042-91E0-E4C5967A636B","type":"StartBlock","disabled":false,"name":"Start","displayName":"Start","comment":"","childId":"A5E03623-06D1-4F1E-BA98-B60F310693D9","inputs":[{"id":"run_mode","value":"manual","type":"select","structure":{}}],"settings":[],"collapsed":[{"name":"loop","isCollapsed":false}],"x":0,"y":0},{"id":"A5E03623-06D1-4F1E-BA98-B60F310693D9","type":"SnippetBlock","disabled":false,"name":"GetTenantNameAndRegion","displayName":"Qlik Platform Operations - Get Tenant Name And Region","comment":"","childId":"74A6433E-DFC2-4F5B-818F-CDD6EF9B9D14","inputs":[{"id":"575d1740-b1e2-11ed-958a-598edfec33b8","value":"platformoperations.eu.qlikcloud.com","type":"string","structure":[]}],"settings":[{"id":"datasource","value":null,"type":"select","structure":[]},{"id":"blendr_on_error","value":"stop","type":"select","structure":[]},{"id":"automations_censor_data","value":false,"type":"checkbox","structure":[]}],"collapsed":[{"name":"loop","isCollapsed":false}],"x":0,"y":240,"datasourcetype_guid":"c7e48240-e0f2-11ec-ada1-d5ef75014b77","snippet_guid":"bd5c1ce0-ad14-11ed-83f6-1d42e53790dd"},{"id":"C27F51DC-4E56-4E59-9E2D-FC37DAD84C3E","type":"SnippetBlock","disabled":false,"name":"GetTenantNameAndRegion2","displayName":"Qlik Platform Operations - Get Tenant Name And Region 2","comment":"","childId":"14E517B3-780F-434B-B0A4-DFE733657F88","inputs":[{"id":"575d1740-b1e2-11ed-958a-598edfec33b8","value":"m5lzzggz5xn60m5.eu.qlikcloud.com","type":"string","structure":[]}],"settings":[{"id":"datasource","value":null,"type":"select","structure":[]},{"id":"blendr_on_error","value":"stop","type":"select","structure":[]},{"id":"automations_censor_data","value":false,"type":"checkbox","structure":[]}],"collapsed":[{"name":"loop","isCollapsed":false}],"x":773,"y":293,"datasourcetype_guid":"c7e48240-e0f2-11ec-ada1-d5ef75014b77","snippet_guid":"bd5c1ce0-ad14-11ed-83f6-1d42e53790dd"},{"id":"74A6433E-DFC2-4F5B-818F-CDD6EF9B9D14","type":"EndpointBlock","disabled":false,"name":"listUsers","displayName":"Qlik Platform Operations - List Users","comment":"","childId":"C27F51DC-4E56-4E59-9E2D-FC37DAD84C3E","inputs":[{"id":"447b9eb0-7634-11ed-a9df-a788128e422e","value":"{$.GetTenantNameAndRegion}","type":"string","structure":[]},{"id":"eb56ff20-9ca8-11ed-82cb-752b6b37b1a7","value":"email eq \"my.email@qlik.com\"","type":"string","structure":[]}],"settings":[{"id":"datasource","value":null,"type":"select","structure":[]},{"id":"maxitemcount","value":"","type":"string","structure":[]},{"id":"blendr_on_error","value":"stop","type":"select","structure":[]},{"id":"cache","value":"0","type":"select","structure":[]},{"id":"automations_censor_data","value":false,"type":"checkbox","structure":[]}],"collapsed":[{"name":"loop","isCollapsed":false}],"x":-292,"y":106,"datasourcetype_guid":"c7e48240-e0f2-11ec-ada1-d5ef75014b77","endpoint_guid":"445157c0-7634-11ed-9b40-9720b0f37135","endpoint_role":"list"},{"id":"14E517B3-780F-434B-B0A4-DFE733657F88","type":"EndpointBlock","disabled":false,"name":"listRoles","displayName":"Qlik Platform Operations - List Roles","comment":"","childId":"0F4439A8-85E5-4C66-B4C3-33FCC543CFBB","inputs":[{"id":"bae46270-b76f-11ed-a52b-d71383a5b940","value":"{$.GetTenantNameAndRegion2}","type":"string","structure":[]},{"id":"35bbb150-b77a-11ed-9a99-9b0cd6b2a9ab","value":"name eq \"TenantAdmin\"","type":"string","structure":[]}],"settings":[{"id":"datasource","value":null,"type":"select","structure":[]},{"id":"maxitemcount","value":"","type":"string","structure":[]},{"id":"blendr_on_error","value":"stop","type":"select","structure":[]},{"id":"cache","value":"0","type":"select","structure":[]},{"id":"automations_censor_data","value":false,"type":"checkbox","structure":[]}],"collapsed":[{"name":"loop","isCollapsed":false}],"x":-290,"y":23,"datasourcetype_guid":"c7e48240-e0f2-11ec-ada1-d5ef75014b77","endpoint_guid":"ba493570-b76f-11ed-b6ab-6fd465c15105","endpoint_role":"list"},{"id":"D9B3C62F-33CB-4174-BAA8-385F0A0151A9","type":"EndpointBlock","disabled":false,"name":"createUser","displayName":"Qlik Platform Operations - Create User","comment":"","childId":"78C680FC-9D58-4311-9124-13772506F49D","inputs":[{"id":"6c07a470-44c9-11ed-81ec-2dfd98774628","value":"{$.GetTenantNameAndRegion2}","type":"string","structure":[]},{"id":"6beaed10-44c9-11ed-9f5a-2de80bbba99e","value":"{$.listUsers[0].name}","type":"string","structure":[]},{"id":"ca85a980-b9c0-11ed-823f-0315a7948c75","value":"{$.listUsers[0].email}","type":"string","structure":[]},{"id":"4410c760-44ca-11ed-b584-69b354d9bb1f","value":"{ $.listUsers[0].subject }","type":"string","structure":[]},{"id":"32d487a0-44ca-11ed-842e-55c135bb046d","value":"{json: { $.transformList }}","type":"string","structure":[]}],"settings":[{"id":"datasource","value":null,"type":"select","structure":[]},{"id":"blendr_on_error","value":"stop","type":"select","structure":[]},{"id":"automations_censor_data","value":false,"type":"checkbox","structure":[]}],"collapsed":[{"name":"loop","isCollapsed":false}],"x":792,"y":662,"datasourcetype_guid":"c7e48240-e0f2-11ec-ada1-d5ef75014b77","endpoint_guid":"6bd82bf0-44c9-11ed-80c7-0507c09f13f9","endpoint_role":"create"},{"id":"0F4439A8-85E5-4C66-B4C3-33FCC543CFBB","type":"TransformListBlock","disabled":false,"name":"transformList","displayName":"Transform List","comment":"","childId":"D9B3C62F-33CB-4174-BAA8-385F0A0151A9","inputs":[{"id":"list","value":"{ $.listRoles }","type":"string","structure":[]},{"id":"mapping","value":[{"key":"id","value":"{ $.transformList.item.id }"}],"type":"object","mode":"keyValue","structure":[]}],"settings":[{"id":"automations_censor_data","value":false,"type":"checkbox","structure":[]}],"collapsed":[{"name":"loop","isCollapsed":false}],"x":-238,"y":573.4951171875},{"id":"78C680FC-9D58-4311-9124-13772506F49D","type":"ShowBlock","disabled":false,"name":"output","displayName":"Output","comment":"","childId":null,"inputs":[{"id":"input","value":"{ $.createUser }","type":"string","structure":[]}],"settings":[{"id":"display_mode","value":"add","type":"select","structure":[]}],"collapsed":[{"name":"loop","isCollapsed":false}],"x":-307,"y":711.223388671875}],"variables":[]}
Next steps
Now that you are connected, move on to Configure a tenant.