问题描述
在Azure Redis的导出页面,突然不能配置Storage Account的SAS作为授权方式。
那么是否可以通过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等信息后,替换如下<xxxxx>内容:
az redis export -n <redis-name> -g <resource-group> --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操作。如无,则需要添加权限。
(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