根据标签自动锁定资源 - Microsoft Azure

Automatically lock resources based on the tags - Microsoft Azure

我想找到一种方法,当资源在 Microsoft Azure 中具有特定标记和值时自动锁定资源。

例如,如果资源的标记 "Important resource" 设置为 "yes",则应在此资源上创建 "CanNotDelete" 锁。 我已经尝试了一些关于策略和 "DeployIfNotExists" 效果的东西,但我没有找到我正在寻找的东西(甚至不确定那个效果是否可以做我想要的)。我真的不知道去哪里解决我的问题。

我想我可以用 Powershell 做到这一点,但我希望它在创建新资源时是自动的,而不必启动 Powershell 脚本来锁定资源。

希望一切都清楚,谢谢。

我不知道你部署的频率有多高,或者你的要求对时间有多敏感,但如果你能在 Powershell 中编写一个解决方案(看起来 Get-AzResource with the -Tag param would work) you could run it in a timer-triggered Azure Function 基本上是免费的。