Migration tooling
Simplify the migration process of Rules to Actions by using the Rule Migration tooling in the Auth0 Dashboard. In addition to facilitating the switch from a Rule to an Action, the new tooling also offers built-in guidance and fixes for common Rule patterns.
Before migration
Before you start the migration, visit Migrate from Rules to Actions. This migration guide is an excellent resource that explains the differences between Rules and Actions and is a helpful tool in the migration journey.
Rule migration order
Rules execute before Actions, which implies that Rules should be migrated in reverse runtime order. Migrate the last Rule to execute in your existing flow and work your way to the first Rule in reverse, chronological order.
Failing to migrate in this order can result in errors due to unanticipated side effects caused by dependencies in the ordering of Rules and Actions.
Safely rolling back
The migration tooling allows you to safely and easily roll back if something goes wrong. Re-enable your Rule and skip the corresponding Action logic.
Migrating a Rule
To begin migrating your Rule, select Auth Pipeline > Rules. Once selected, your Rules appear with an option to migrate each of them individually.
![](http://images.ctfassets.net/cdy7uua7fh8z/79DmJp8C2vYZpdos51Z0nM/5a665d04c66dd9f0b8f0e25198cb9e4e/SS1_Dashboard_migration_screenshot.png)
Migrate to Action
After selecting Migrate to Action, the tooling prompts you to create a new Action.
![](http://images.ctfassets.net/cdy7uua7fh8z/1A8FnVyvqAwW8hbrkOQDoG/f83ba9d5157db14ac2a3a666b2280574/SS2_Migrate_to_Action_screenshot.png)
After you select Create, the new Action is created and you are presented with the Actions Editor.
![](http://images.ctfassets.net/cdy7uua7fh8z/2A10fE69aVngEcL2ZQCqWX/720dca2a8e6005c9378efad3bc140af0/Screenshot_2024-06-06_at_11.55.38_AM.png)
If the Rule is migrated to Actions and still active, the Rule exits before the logic runs.
This runs by calling api.rules.wasExecuted()
. If the wasExecuted
function consumes a string containing the Rule ID, it returns true
if the Rule has already run (and otherwise, returns false
).
This is a helpful tool to prevent your logic from running twice. As soon as you disable the referenced Rule, the function returns false
and the business logic now executes in the Action.
For more information about the api.rules.wasExecuted()
function, refer to Actions Triggers: post-login - API Object.
Rewrite Rule code
Select the Rules button in the Actions Editor to load the Rules Migration tool. There, you can quickly reference the code of the migrated Rule. You should review the code of the selected Rule in the sidebar.
Copy the contents of the Rule function and paste it under the // YOUR CODE HERE
comment in the Action. It’s likely that this code is not adapted for the Actions programming model.
![](http://images.ctfassets.net/cdy7uua7fh8z/2jWCZFnfERuN7NzBPrpCDn/80ba271699893a007dac7baaf2dd44cb/Screenshot_2024-06-06_at_11.57.03_AM.png)
The Actions Editor provides feedback where code must be refactored. The editor also provides suggestions on how to automatically fix most situations - to review the suggestion or fix, hover over the underlined code:
![](http://images.ctfassets.net/cdy7uua7fh8z/5jRGI4iDX9ZgwcPRADTbZ1/caa90923a76800526871b137806e2af3/Screenshot_2024-06-06_at_11.58.07_AM.png)
You may be able to apply Action-specific updates by selecting an option from the Quick Fix modal.
![](http://images.ctfassets.net/cdy7uua7fh8z/qTS4RD6cjWFVfI0T9Uph3/45776c464f7247ddd8e91860f4646f2e/Screenshot_2024-06-06_at_11.58.48_AM.png)
When you select the recommended fix, your code automatically updates to be compatible.
![](http://images.ctfassets.net/cdy7uua7fh8z/1cAq5A1MNVLPAsinHjtROh/c71276afd1f6df9e01d71cc869778907/Screenshot_2024-06-06_at_11.59.37_AM.png)
There are some situations where fixes cannot be applied automatically but guidance is still provided:
![](http://images.ctfassets.net/cdy7uua7fh8z/4Lx3RxJh8v4tj1J2SpPVvU/0ff35b0f40bb24d195ab2f4b06817d86/Screenshot_2024-06-06_at_12.00.22_PM.png)
For example: in the case of the Rule’s callback
function, it is recommended to use api.access.deny
for errors, or just return
in successful cases.
Test the new Action
Actions can be tested directly in the editor, as this is an essential part of the migration journey. For more information, review Test Actions.
Automatically enabling the Action
When the Action code is updated and you are ready to make the switch:
Select Deploy.
On the alert that confirms your deployment, select Add to flow.
Add your newly created Action to the flow, then select Apply.
Select Continue, and disable any Rules selected to simultaneously enable the new Action and disable the original Rule. If you are not ready, select Cancel, and you can disable the Rule later to activate the migrated Action logic.
For more information on adding your Action to the flow, refer to Write your first Action.
![](http://images.ctfassets.net/cdy7uua7fh8z/47iWYB5o5CyhxvQyHdSTS4/833e6d4541fea132faf793c3e12563a8/SS10.png)
Migrate remaining rules
This process can be repeated to migrate each Rule in your login flow. Remember, Rules should be migrated in the reverse order they execute during the login flow.