Skip to content

【Azure Cache for Redis】Redis的导出页面无法配置Storage SAS时通过az cli来完成

lulight edited this page Nov 29, 2023 · 1 revision

问题描述

在Azure Redis的导出页面,突然不能配置Storage Account的SAS作为授权方式。 image.png

那么是否可以通过AZ CLI或者是Powershell来实现SAS的配置呢?

问题解答

可以的。使用  az redis export 可以实现

az redis export --container --prefix
                [--auth-method {ManagedIdentity, **SAS**}]
                [--file-format]
                [--ids]
                [--name]
                [--resource-group]
                [--subscription]

准备好Storage Account Blob的SAS URL, Redis Name 和 Resource Group等信息后,替换如下内容:

az redis export -n  -g  --prefix examplePrefix --container "https://your-storage-account.blob.core.chinacloudapi.cn/redis?sp=racwdl&st=xxxx-xx-xxT13:45:12Z&se=xxxx-xx-xxT13:45:12Z&spr=https&sv=2022-11-02&sr=c&sig=********" --preferred-data-archive-auth-method SAS

如出现如下类似的错误信息,则需要考虑当前用户是否有权限执行export操作。如无,则需要添加权限。 image.png

(AuthorizationFailed) The client 'xxxxxxxxxxxxxxxx' with object id 'xxxxxxxx-xxxx-xxxxxxx-xxxx-xxxx' 
does not have authorization to perform action 'Microsoft.Cache/redis/export/action' over scope '/subscriptions/xxxxxx' 
or the scope is invalid. If access was recently granted, please refresh your credentials.
Code: AuthorizationFailed

参考资料

az redis export:https://learn.microsoft.com/en-us/cli/azure/redis?view=azure-cli-latest#az-redis-export

当在复杂的环境中面临问题,格物之道需:浊而静之徐清,安以动之徐生。 云中,恰是如此!

Clone this wiki locally