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:
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?
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