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 a cache instance or export data from a cache instance. You import and export an Azure Cache for Redis Database (RDB) snapshot from a cache to a blob in an Azure Storage Account. Import/Export is supported in the Premium tiers.

  • 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.

For information on which Azure Cache for Redis tiers support import and export, see feature comparison.

Import

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 prepopulated 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.

Note

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.

  1. To import one or more exported cache blobs, browse to your cache in the Azure portal and select Import data from the Resource menu. In the working pane, you see Choose Blob(s) where you can find RDB files.

    Screenshot showing Import data selected in the Resource menu.

  2. Select Choose Blob(s) and select the storage account that contains the data to import.

    Screenshot showing a list of storage accounts.

  3. Select the container that contains the data to import.

    Screenshot showing list of containers from the previously chosen storage account.

  4. Select one or more blobs to import by selecting the area to the left of the blob name, and then Select.

    Screenshot showing a blob from the container.

  5. Select Import to begin the import process.

    Important

    The cache is not accessible by cache clients during the import process, and any existing data in the cache is deleted.

    Screenshot showing the Import button to select to begin the import.

    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.

    Screenshot showing the import progress in the notifications area.

Export

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.

  1. 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. You see Choose Storage Container in the working pane.

    Screenshot showing Export data selected in the Resource menu

  2. Select Choose Storage Container and to display a list of available storage accounts. Select the storage account you want. The storage account must be in the same subscription and region as your cache.

    Important

    • 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.
    • If your cache data export to Firewall-enabled storage accounts fails, refer to How to export if I have firewall enabled on my storage account?

    For more information, see Azure storage account overview.

    Screenshot showing a list of containers in the working pane.

  3. Choose the storage container you want to hold your export, then Select. If you want a new container, select Add Container to add it first, and then select it from the list.

    Screenshot of a list of containers with one highlighted and a select button.

  4. 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.

    Screenshot showing a blob name prefix and an Export button.

    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.

    Screenshot showing the export progress in the notifications area.

    Caches remain available for use during the export process.

Import/Export FAQ

This section contains frequently asked questions about the Import/Export feature.

What pricing tiers can use Import/Export?

Import/Export is available in the Premium tiers.

Can I import data from any Redis server?

Yes, you can import data that was exported from Azure Cache for Redis instances. 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.

Important

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 nonclustered 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 databases limit 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 databases that 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.

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?

Yes, for PowerShell instructions see To import an Azure Cache for Redis and To export an Azure Cache for Redis.

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. If you're using an access key to authenticate a storage account, having firewall exceptions on the storage account tends to cause the import/export process to fail.

How to export if I have firewall enabled on my storage account?

For firewall enabled storage accounts, we need to check “Allow Azure services on the trusted services list to access this storage account” then, use managed identity (System/User assigned) and provision Storage Blob Data Contributor RBAC role for that object ID.

More information here - Managed identity for storage accounts - Azure Cache for Redis

Next steps

Learn more about Azure Cache for Redis features.