获取Azure自动化帐户的Sku

时间:2019-08-01 15:13:25

标签: azure powershell azure-powershell arm-template

我正在尝试对不同订阅中的现有自动化帐户启用诊断设置。

到目前为止,我的脚本不属于下列主题。

  • 获取所有自动化帐户
  • 遍历它们中的每一个。
  • 将ARM模板中的参数值更改为检索到的自动化帐户的值
  • 部署用于在该特定自动化帐户上启用诊断设置的ARM模板。

    {
            "name": "[parameters('AutomationAccountName')]",
            "type": "Microsoft.Automation/automationAccounts",
            "apiVersion": "2015-10-31",
            "properties": {
                "sku": {
                    "name" : "Basic"
                }
            },
            "location": "[parameters('location')]",
            "resources": [
                {
                    "type": "providers/diagnosticSettings"
        Enabling all sort of logs in the diagnostic settings ..
    

这很好。 但是我现在面临的问题是,此处的sku设置为基本。但是我不确定使用get-AzAutomationAccount命令检索的每个自动化帐户都是这种情况。

我已经搜索过从get-AzAutomationAccount获取计划值,并将其保存在ARM模板中,但似乎为空。

是否还有其他方法可以检索每个Azure自动化帐户的sku。

如果我读了the official doc of Microsoft,通常也不需要SKU对象。但是,每当我删除sku对象或将其保留为空时,部署就会失败。

有人知道如何解决此问题吗?

1 个答案:

答案 0 :(得分:1)

命令Get-AzAutomationAccount将不会返回sku属性,而只会返回Plan

enter image description here

如果要获取sku,可以使用以下命令。

$sku = (Get-AzResource -ResourceGroupName "<resource group name>" -ResourceType Microsoft.Automation/automationAccounts -ResourceName "<automation account name>").properties.sku
$sku | ConvertTo-Json

enter image description here