|
1 | 1 | ---
|
2 | 2 | title: Migrate to Azure Cache for Redis
|
3 |
| -description: Learn how to migrate your existing cache to Azure Cache for Redis |
| 3 | +description: Learn how to migrate an existing cache to Azure Cache for Redis or migrate between Azure Cache for Redis instances. |
4 | 4 | ms.topic: conceptual
|
5 | 5 | ms.custom:
|
6 | 6 | - ignite-2024
|
7 | 7 | ms.collection:
|
8 | 8 | - migration
|
9 | 9 | - aws-to-azure
|
10 |
| -ms.date: 11/17/2021 |
| 10 | +ms.date: 05/22/2025 |
11 | 11 | appliesto:
|
12 | 12 | - ✅ Azure Cache for Redis
|
13 | 13 |
|
14 | 14 | ---
|
15 |
| -# Migrate to Azure Cache for Redis |
| 15 | +# Migrate to or between Azure Cache for Redis instances |
16 | 16 |
|
17 |
| -This article describes a number of approaches to migrate an existing Redis cache running on-premises or in another cloud service to Azure Cache for Redis. |
| 17 | +This article describes several Azure Cache for Redis migration scenarios. You can migrate open-source Redis caches running on-premises or in cloud virtual machines (VMs), or hosted caches from other cloud platforms, to Azure Cache for Redis. |
18 | 18 |
|
19 |
| -## Migration scenarios |
| 19 | +You can also migrate one Azure Cache for Redis instance to another instance. If you only need to move an Azure Redis cache from one Azure region to another, see [Move Azure Cache for Redis instances to different regions](cache-moving-resources.md). |
20 | 20 |
|
21 |
| -Open-source Redis can run in many compute environments. Common examples include: |
22 |
| - |
23 |
| -- **On-premises** - Redis caches running in private data centers. |
24 |
| -- **Cloud-based VMs** - Redis caches running on Azure VMs, AWS EC2, and so on. |
25 |
| -- **Hosting services** - Managed Redis services such as AWS ElastiCache. |
26 |
| - |
27 |
| -If you have such a cache, you may be able to move it to Azure Cache for Redis with minimal interruption or downtime. |
28 |
| - |
29 |
| -If you're looking to move from one Azure region to another, we recommend you see our [Move Azure Cache for Redis instances to different regions](cache-moving-resources.md) article. |
| 21 | +Open-source Redis can run in many compute environments, such as private on-premises data centers or cloud-hosted VMs. Other hosting platforms like Amazon Web Services (AWS) host Redis cache services like AWS ElastiCache. You can usually migrate these Redis caches to Azure Cache for Redis with minimal interruption or downtime. |
30 | 22 |
|
31 | 23 | ## Migration options
|
32 | 24 |
|
33 |
| -There are different ways that you can switch from one cache to another. Depending on where your cache is and how your application interacts with it, one method will be more useful than the others. Some of the frequently used migration strategies are detailed below. |
| 25 | +How you migrate from one cache to another depends on where your cache exists and how your application interacts with it. The following table lists frequently used migration strategies. |
34 | 26 |
|
35 | 27 | | Option | Advantages | Disadvantages |
|
36 | 28 | | ------------ | ---------- | ------------- |
|
37 |
| - | Create a new cache | Simplest to implement. | Need to repopulate data to the new cache, which may not work with many applications. | |
38 |
| - | Export and import data via RDB file | Compatible with any Redis cache generally. | Some data could be lost, if they're written to the existing cache after the RDB file is generated. | |
39 |
| - | Dual-write data to two caches | No data loss or downtime. Uninterrupted operations of the existing cache. Easier testing of the new cache. | Needs two caches for an extended period of time. | |
40 |
| - | Migrate data programmatically | Full control over how data are moved. | Requires custom code. | |
| 29 | + | Create a new cache | Simplest to implement. | Must repopulate data to the new cache, which might not work with some applications. | |
| 30 | + | Export and import data via read-only database (RDB) file. | Compatible with any Redis cache. | Data written to the existing cache after the RDB file is generated could be lost. | |
| 31 | + | Dual-write data to two caches. | No data loss or downtime, no interrupted cache operations, and easier testing. | Needs two caches for an extended time period. | |
| 32 | + | Migrate data programmatically. | Full control over how data is moved. | Requires custom code. | |
41 | 33 |
|
42 |
| -### Create a new Azure Cache for Redis |
| 34 | +### Create a new cache |
43 | 35 |
|
44 |
| -This approach technically isn't a migration. If losing data isn't a concern, the easiest way to move to Azure Cache for Redis is to create cache instance and connect your application to it. For example, if you use Redis as a look-aside cache of database records, you can easily rebuild the cache from scratch. |
| 36 | +If uninterrupted operations and potential data loss aren't concerns, the easiest way to move data to Azure Cache for Redis is to create an Azure Redis cache instance and connect your application to it. For example, if you use Redis as a look-aside cache of database records, you can easily rebuild the cache from scratch. This approach isn't technically a migration. |
45 | 37 |
|
46 | 38 | General steps to implement this option are:
|
47 | 39 |
|
48 |
| -1. Create a new Azure Cache for Redis instance. |
49 |
| - |
50 |
| -1. Optionally, try out the new [Azure Managed Redis (preview)](../redis/overview.md). |
51 |
| - |
52 |
| -2. Update your application to use the new instance. |
53 |
| - |
| 40 | +1. Create a new Azure Cache for Redis instance. Optionally, try out [Azure Managed Redis](../redis/overview.md). |
| 41 | +1. Update your application to use the new Azure Redis instance. |
54 | 42 | 3. Delete the old Redis instance.
|
55 | 43 |
|
56 | 44 | ### Export data to an RDB file and import it into Azure Cache for Redis
|
57 | 45 |
|
58 |
| -Open-source Redis defines a standard mechanism for taking a snapshot of a cache's in-memory dataset and saving it to a file. This file, called RDB, can be read by another Redis cache. [Azure Cache for Redis premium tier](cache-overview.md#service-tiers) supports importing data into a cache instance via RDB files. You can use an RDB file to transfer data from an existing cache to Azure Cache for Redis. |
| 46 | +Open-source Redis defines a standard mechanism to take a snapshot of a cache's in-memory dataset and save it to an RDB file that any Redis cache can read. Azure Cache for Redis [Premium tier](cache-overview.md#service-tiers) supports importing data into a cache instance via RDB file. You can use the RDB file to transfer data from an existing cache to Azure Cache for Redis. |
59 | 47 |
|
60 | 48 | > [!IMPORTANT]
|
61 |
| -> RDB file format can change between Redis versions and may not maintain backward-compatibility. The Redis version of the cache you're exporting from should be equal or less than the version provided by Azure Cache for Redis. |
62 |
| -> |
| 49 | +> RDB file format can change between Redis versions and might not maintain backward compatibility. The Redis version of the cache you export should be equal to or lower than the version that Azure Cache for Redis provides. |
63 | 50 |
|
64 | 51 | General steps to implement this option are:
|
65 | 52 |
|
66 |
| -1. Create a new Azure Cache for Redis instance in the premium tier that is the same size as (or bigger than) the existing cache. |
67 |
| - |
68 |
| -2. Save a snapshot of the existing Redis cache. You can [configure Redis to save snapshots](https://redis.io/topics/persistence) periodically, or run the process manually using the [SAVE](https://redis.io/commands/save) or [BGSAVE](https://redis.io/commands/bgsave) commands. The RDB file is named “dump.rdb” by default and will be located at the path specified in the *redis.conf* configuration file. |
69 |
| - |
70 |
| - > [!NOTE] |
71 |
| - > If you’re migrating data within Azure Cache for Redis, see [these instructions on how to export an RDB file](cache-how-to-import-export-data.md) or use the [PowerShell Export cmdlet](/powershell/module/az.rediscache/export-azrediscache) instead. |
72 |
| - > |
| 53 | +1. Save a snapshot of the existing Redis cache. You can [configure Redis to save snapshots](https://redis.io/topics/persistence) periodically, or save one manually using the [SAVE](https://redis.io/commands/save) or [BGSAVE](https://redis.io/commands/bgsave) commands. The RDB file is named *dump.rdb* by default and is located at the path specified in the *redis.conf* configuration file. |
| 54 | +1. Create a new Premium-tier Azure Cache for Redis instance that's at least as large as the existing cache. |
| 55 | +1. Copy the RDB file to an Azure storage account in the region where your new cache is located. You can use `AzCopy` for this task. |
| 56 | +1. [Import](cache-how-to-import-export-data.md#import) the RDB file into the new cache. You can also use the PowerShell [Import-AzRedisCache](/powershell/module/az.rediscache/import-azrediscache) cmdlet. |
| 57 | +1. Update your application to use the new cache instance. |
73 | 58 |
|
74 |
| -3. Copy the RDB file to an Azure storage account in the region where your new cache is located. You can use AzCopy for this task. |
75 |
| - |
76 |
| -4. Import the RDB file into the new cache using these [import instructions](cache-how-to-import-export-data.md) or the [PowerShell Import cmdlet](/powershell/module/az.rediscache/import-azrediscache). |
| 59 | +> [!NOTE] |
| 60 | +> To migrate data from another Azure Redis instance, first [export](cache-how-to-import-export-data.md#export) the RDB file from that instance, or use the PowerShell [Export-AzRedisCache](/powershell/module/az.rediscache/export-azrediscache) cmdlet. |
77 | 61 |
|
78 |
| -5. Update your application to use the new cache instance. |
| 62 | +### Write to two Redis caches during migration |
79 | 63 |
|
80 |
| -### Write to two Redis caches simultaneously during migration period |
| 64 | +Rather than moving data between caches, you can temporarily set your application to write data to both an existing cache and a new one. The application reads data from the existing cache initially. When the new cache has enough data, you can switch the application to that cache and retire the old one. |
81 | 65 |
|
82 |
| -Rather than moving data directly between caches, you may use your application to write data to both an existing cache and a new one you're setting up. The application will still read data from the existing cache initially. When the new cache has the necessary data, you switch the application to that cache and retire the old one. Let's say, for example, you use Redis as a session store and the application sessions are valid for seven days. After writing to the two caches for a week, you'll be certain the new cache contains all non-expired session information. You can safely rely on it from that point onward without concern over data loss. |
| 66 | +For example, suppose you use Redis as a session store and the application sessions expire after seven days. After writing to both caches for seven days, you know the new cache contains all nonexpired session information and you can safely rely on it from that point on. You can then retire the old cache. |
83 | 67 |
|
84 | 68 | General steps to implement this option are:
|
85 | 69 |
|
86 |
| -1. Create a new Azure Cache for Redis instance in the premium tier that is the same size as (or bigger than) the existing cache. |
87 |
| - |
88 |
| -2. Modify application code to write to both the new and the original instances. |
89 |
| - |
90 |
| -3. Continue reading data from the original instance until the new instance is sufficiently populated with data. |
91 |
| - |
92 |
| -4. Update the application code to reading and writing from the new instance only. |
93 |
| - |
94 |
| -5. Delete the original instance. |
| 70 | +1. Create a new Premium-tier Azure Cache for Redis instance that's at least as large as the existing cache. |
| 71 | +1. Modify your application code to write to both the new and the original instances. |
| 72 | +1. Continue using data from the original instance until the new instance is sufficiently populated with data. |
| 73 | +1. Update the application code to reading and writing from the new instance only. |
| 74 | +1. Delete the original instance. |
95 | 75 |
|
96 | 76 | ### Migrate programmatically
|
97 | 77 |
|
98 |
| -You can create a custom migration process by programmatically reading data from an existing cache and writing them into Azure Cache for Redis. This [open-source tool](https://github.com/deepakverma/redis-copy) can be used to copy data from one Azure Cache for Redis instance to another. A [compiled version](https://github.com/deepakverma/redis-copy/releases/download/alpha/Release.zip) is available as well. You may also find the source code to be a useful guide for writing your own migration tool. |
| 78 | +You can create a custom migration by programmatically reading data from an existing cache and writing it into Azure Cache for Redis. For example, you can use the open-source [redis-copy](https://github.com/deepakverma/redis-copy) tool to copy data from one Azure Redis instance to another. |
| 79 | + |
| 80 | +The source code can be a useful guide for writing your own migration tool. A [compiled version](https://github.com/deepakverma/redis-copy/releases/download/alpha/Release.zip) is also available. |
99 | 81 |
|
100 | 82 | > [!NOTE]
|
101 | 83 | > This tool isn't officially supported by Microsoft.
|
102 |
| -> |
103 | 84 |
|
104 | 85 | General steps to implement this option are:
|
105 | 86 |
|
106 |
| -1. Create a VM in the region where the existing cache is located. If your dataset is large, choose a relatively powerful VM to reduce copying time. |
107 |
| - |
108 |
| -2. Create a new Azure Cache for Redis instance. |
109 |
| - |
110 |
| -3. Flush data from the new cache to ensure that it's empty. This step is required because the copy tool itself doesn't overwrite any existing key in the target cache. |
111 |
| - |
112 |
| - > [!IMPORTANT] |
113 |
| - > Make sure to NOT flush from the source cache. |
114 |
| - > |
115 |
| -
|
116 |
| -4. Use an application such as the open-source tool above to automate the copying of data from the source cache to the target. Remember that the copy process could take a while to complete depending on the size of your dataset. |
| 87 | +1. Create an Azure virtual machine (VM) in the same region as the existing cache. If your dataset is large, choose a powerful VM to reduce copying time. |
| 88 | +1. Create a new Azure Cache for Redis instance and make sure that it's empty. The `redis-copy` tool doesn't overwrite any existing keys in the target cache. |
| 89 | +4. Use an application such as `redis-copy` to automate copying the data from the source cache to the target cache. The copy process could take a while depending on the size of your dataset. |
117 | 90 |
|
118 |
| -## Next steps |
119 |
| -Learn more about Azure Cache for Redis features. |
| 91 | +## Related content |
120 | 92 |
|
121 |
| -* [Azure Cache for Redis service tiers](cache-overview.md#service-tiers) |
122 |
| -* [Import data](cache-how-to-import-export-data.md#import) |
| 93 | +- [Azure Cache for Redis service tiers](cache-overview.md#service-tiers) |
| 94 | +- [Import and export data](cache-how-to-import-export-data.md#import) |
0 commit comments