自动从Runbook中标记资源组 [英] Automate tagging resource groups from a runbook

查看:85
本文介绍了自动从Runbook中标记资源组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个脚本,用于识别空资源组并使用值"Empty"标记它们:$ null


它基本上通过循环来达到目的通过我的所有订阅,并标记资源组。


当我开始使用Runbook通过自动化帐户执行此操作时,它失败了。


<我已将其修改为在Runbook中使用AzureRm模块,尝试遵循类似性质的帖子中的想法,但我无法休息。 Runbook代码 逻辑看起来像这样:


$ TagName = " Empty"

解决方案

您好RoyalMisfit,



您收到该错误因为您没有将哈希表中的键声明为字符串(或用双引号括起来)。声明哈希表的正确方法是

 


tags = @ {" Key" ; =" Value"}




您想要将标记添加为" Empty":


null 所以声明你的哈希表为

 

I have a script that serves the purpose of identifying empty resource groups and tagging them with the values "Empty":$null

It basically serves the purpose by looping through all of my subscriptions, and tagging the resource groups.

When I set out to do this using an Automation Account via Runbook, it fails miserably.

I've modified it to use AzureRm modules in the runbook, tried following the ideas from the posts of similar nature, but I can't catch a break. The runbook code  logic looks like this:

$TagName = "Empty"

解决方案

Hi RoyalMisfit,

You get that error because you have not declared the key's in the hashtable as strings (or enclosed with doublequotes). The right way to declare the hashtable is


tags = @{"Key"= "Value"}


As you want to add the tag as "Empty":


null so declare your hashtable as


这篇关于自动从Runbook中标记资源组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆