Score:1

How to export Azure REDIS data to BLOB storage with a Automation Runbook?

sy flag

I'm struggling with setting up a runbook that overnight exports my REDIS Premium data to a BLOB container. This might be due to my lack of Powershell experience.

So far I came up with this:

# Ensures you do not inherit an AzContext in your runbook
Disable-AzContextAutosave -Scope Process

# Connect to Azure with system-assigned managed identity
$AzureContext = (Connect-AzAccount -Identity).context

# Set and store context
$AzureContext = Set-AzContext -SubscriptionName $AzureContext.Subscription -DefaultProfile $AzureContext

# Import Azure Modules
Import-Module Az.Accounts
Import-Module Az.RedisCache

$RedisResourceGroupName = Get-AutomationVariable -Name 'RedisResourceGroupName'
$RedisStorageName = Get-AutomationVariable -Name 'RedisStorageName'
$RedisExportDataContainerUrl = Get-AutomationVariable -Name 'RedisExportDataContainerUrl'
$EpochTimeStamp = Get-Date -UFormat %s
$BlobPrefix = $EpochTimeStamp + "_"

$exportOutput = Export-AzRedisCache -ResourceGroupName $RedisResourceGroupName -Name $RedisStorageName -Prefix $BlobPrefix -Container $RedisExportDataContainerUrl #-PreferredDataArchiveAuthMethod ManagedIdentity
Write-Output $exportOutput

Two questions:

  1. For this to not throw a Forbidden error, I added the Managed Identity of the AutomationAccount to Owner-role. Other roles did not seem to have enough permissions. Is this the only way?

  2. This script takes a long time (12GB of Data) but it ends up with this error message

      Export-AzRedisCache : Long running operation failed with status 'Conflict'. At line:20 char:17 + ... ortOutput = Export-AzRedisCache -ResourceGroupName $RedisResourceGrou ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : CloseError: (:) [Export-AzRedisCache], CloudException + FullyQualifiedErrorId: Microsoft.Azure.Commands.RedisCache.ExportAzureRedisCache
    
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.