Import and Export data in Azure Cache for Redis
Import/Export is an Azure Cache for Redis data management operation. It allows you to import data into Azure Cache for Redis or export data from Azure Cache for Redis by importing and exporting an Azure Cache for Redis Database (RDB) snapshot from a premium cache to a blob in an Azure Storage Account.
- Export - you can export your Azure Cache for Redis RDB snapshots to a Page Blob.
- Import - you can import your Azure Cache for Redis RDB snapshots from either a Page Blob or a Block Blob.
Import/Export enables you to migrate between different Azure Cache for Redis instances or populate the cache with data before use.
This article provides a guide for importing and exporting data with Azure Cache for Redis and provides the answers to commonly asked questions.
Import/Export is only available for Premium tier caches.
Use import to bring Redis compatible RDB files from any Redis server running in any cloud or environment, including Redis running on Linux, Windows, or any cloud provider such as Amazon Web Services and others. Importing data is an easy way to create a cache with pre-populated data. During the import process, Azure Cache for Redis loads the RDB files from Azure storage into memory and then inserts the keys into the cache.
Before beginning the import operation, ensure that your Redis Database (RDB) file or files are uploaded into page or block blobs in Azure storage, in the same region and subscription as your Azure Cache for Redis instance. For more information, see Get started with Azure Blob storage. If you exported your RDB file using the Azure Cache for Redis Export feature, your RDB file is already stored in a page blob and is ready for importing.
To import one or more exported cache blobs, browse to your cache in the Azure portal and select Import data from the Resource menu.
Select Choose Blob(s) and select the storage account that contains the data to import.
Select the container that contains the data to import.
Select one or more blobs to import by selecting the area to the left of the blob name, and then Select.
Select Import to begin the import process.
The cache is not accessible by cache clients during the import process, and any existing data in the cache is deleted.
You can monitor the progress of the import operation by following the notifications from the Azure portal, or by viewing the events in the audit log.
Export allows you to export the data stored in Azure Cache for Redis to Redis compatible RDB file(s). You can use this feature to move data from one Azure Cache for Redis instance to another or to another Redis server. During the export process, a temporary file is created on the VM that hosts the Azure Cache for Redis server instance. Then, the file is uploaded to the chosen storage account. When the export operation completes with either a status of success or failure, the temporary file is deleted.
To export the current contents of the cache to storage, browse to your cache in the Azure portal and select Export data from the Resource menu.
Select Choose Storage Container and select the storage account you want. The storage account must be in the same subscription and region as your cache.
- Export works with page blobs that are supported by both classic and Resource Manager storage accounts.
- Azure Cache for Redis does not support exporting to ADLS Gen2 storage accounts.
- Export is not supported by Blob storage accounts at this time.
For more information, see Azure storage account overview.
Choose the blob container you want, then Select. To use new a container, select Add Container to add it first and then select it from the list.
Type a Blob name prefix and select Export to start the export process. The blob name prefix is used to prefix the names of files generated by this export operation.
You can monitor the progress of the export operation by following the notifications from the Azure portal, or by viewing the events in the audit log.
Caches remain available for use during the export process.
This section contains frequently asked questions about the Import/Export feature.
- What pricing tiers can use Import/Export?
- Can I import data from any Redis server?
- What RDB versions can I import?
- Is my cache available during an Import/Export operation?
- Can I use Import/Export with Redis cluster?
- How does Import/Export work with a custom databases setting?
- How is Import/Export different from Redis persistence?
- Can I automate Import/Export using PowerShell, CLI, or other management clients?
- I received a timeout error during my Import/Export operation. What does it mean?
- I got an error when exporting my data to Azure Blob Storage. What happened?
What pricing tiers can use Import/Export?
Import/Export is available only in the premium pricing tier.
Can I import data from any Redis server?
Yes, you can importing data exported from Azure Cache for Redis instances, and you can import RDB files from any Redis server running in any cloud or environment. The environments include Linux, Windows, or cloud providers such as Amazon Web Services. To do import this data, upload the RDB file from the Redis server you want into a page or block blob in an Azure Storage Account. Then, import it into your premium Azure Cache for Redis instance. For example, you might want to export the data from your production cache and import it into a cache that is used as part of a staging environment for testing or migration.
To successfully import data exported from Redis servers other than Azure Cache for Redis when using a page blob, the page blob size must be aligned on a 512 byte boundary. For sample code to perform any required byte padding, see Sample page blob upload.
What RDB versions can I import?
Azure Cache for Redis supports RDB import up through RDB version 7.
Is my cache available during an Import/Export operation?
- Export - Caches remain available and you can continue to use your cache during an export operation.
- Import - Caches become unavailable when an import operation starts, and become available for use when the import operation completes.
Can I use Import/Export with Redis cluster?
Yes, and you can import/export between a clustered cache and a non-clustered cache. Since Redis cluster only supports database 0, any data in databases other than 0 isn't imported. When clustered cache data is imported, the keys are redistributed among the shards of the cluster.
How does Import/Export work with a custom databases setting?
Some pricing tiers have different databases limits, so there are some considerations when importing if you configured a custom value for the
databases setting during cache creation.
- When importing to a pricing tier with a lower
databaseslimit than the tier from which you exported:
- If you're using the default number of
databases, which is 16 for all pricing tiers, no data is lost.
- If you're using a custom number of
databasesthat falls within the limits for the tier to which you're importing, no data is lost.
- If you're exported data contained data in a database that exceeds the limits of the new tier, the data from those higher databases isn't imported.
- If you're using the default number of
How is Import/Export different from Redis persistence?
Azure Cache for Redis persistence allows you to persist data stored in Redis to Azure Storage. When persistence is configured, Azure Cache for Redis persists a snapshot the cache data in a Redis binary format to disk based on a configurable backup frequency. If a catastrophic event occurs that disables both the primary and replica cache, the cache data is restored automatically using the most recent snapshot. For more information, see How to configure data persistence for a Premium Azure Cache for Redis.
Import/ Export allows you to bring data into or export from Azure Cache for Redis. It doesn't configure backup and restore using Redis persistence.
Can I automate Import/Export using PowerShell, CLI, or other management clients?
I received a timeout error during my Import/Export operation. What does it mean?
On the left, if you remain on Import data or Export data for longer than 15 minutes before starting the operation, you receive an error with an error message similar to the following example:
The request to import data into cache 'contoso55' failed with status 'error' and error 'One of the SAS URIs provided could not be used for the following reason: The SAS token end time (se) must be at least 1 hour from now and the start time (st), if given, must be at least 15 minutes in the past.
To resolve this error, start the import or export operation before 15 minutes has elapsed.
I got an error when exporting my data to Azure Blob Storage. What happened?
Export works only with RDB files stored as page blobs. Other blob types aren't currently supported, including Blob storage accounts with hot and cool tiers. For more information, see Azure storage account overview.
Learn more about Azure Cache for Redis features.