如何运行脚本刷新所有Azure Redis

问题描述 投票:0回答:1

我尝试在部署Web应用程序后设置结束任务来清理Azure Redis中的缓存,以避免使旧缓存生效。我尝试了 az cli 和 Powershell 这两个命令,它们都进行了相同的重启,但是 Redis 缓存中的所有数据仍然没有刷新,即使在 activilogs 中显示重启后数据将丢失。我已经在 C0 层和 P1 层 Redis 上进行了测试。有人给了我一个刷新所有 Azure Redis 的脚本吗?我只设置 SSL 端口 3380。

这是我运行的命令:

-CLI

az redis 强制重启 --name $Redis --resource-group $ResourceGroup --reboot-type AllNodes

-Powershell:

重置-AzRedisCache -ResourceGroupName $ResourceGroup -Name $Redis -RebootType“AllNodes”-Force

-活动日志:

查看redis工具管理器还有数据:

谢谢你帮助我!

设置任务 Flushall Azure Redis

azure powershell redis azure-cli azure-redis-cache
1个回答
0
投票

命令

force-reboot
用于从此MSDOC

重新启动指定的Redis节点
az redis force-reboot --reboot-type {AllNodes, PrimaryNode, SecondaryNode}
                      [--ids]
                      [--name]
                      [--resource-group]
                      [--shard-id]
                      [--subscription]
  • 使用

    az login
    登录到 Azure。

  • 创建 Azure Redis 缓存

    New-AzRedisCache -ResourceGroupName myGroup -Name mycache -Location "North Central US"
  • 用于使用 PowerShell 清除/刷新 Azure Redis 缓存。
Invoke-Command -ScriptBlock { redis-cli -h <hostname>.redis.cache.windows.net -p <redisPort> -a <password> }

Invoke-Command -ScriptBlock { redis-cli flushall }

输出:

enter image description here

enter image description here

  • 简单的方法是转到概述,单击控制台并执行
    flushall
    命令:

enter image description here

另一种方法:

$redisServer.FlushAllDatabases() # Dispose connection 

$redis_cache.Dispose() Write-Host "Cache flush done" -ForegroundColor Yellow
© www.soinside.com 2019 - 2024. All rights reserved.