0
votes

I am trying to enable diagnostic settings on existing automation accounts in different subscriptions.

So far my script exist out of the following topics.

  • Retrieve all Automation Accounts
  • Loop through every single on of them.
  • Change the value of the parameters in the ARM template to the value of the retrieved automation account
  • Deploy the ARM template that enable diagnostic settings on that specific automation account.

    {
            "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 ..
    

This works fine. But the problem I am facing right now is that the sku is set to basic right here. But I can't be sure that is the case to every single automationaccount I retrieve with the get-AzAutomationAccount command.

I have searched to get the plan value from the get-AzAutomationAccount and save this inside the ARM template but seems to be empty.

Is there any other way to retrieve the sku of each Azure Automation account.

ALSO the SKU object normally is not required if I read the official doc of Microsoft. But whenever I delete the sku object or leave it empty the deployment fails.

Is there anyone who know how to fix this ?

1

1 Answers

1
votes

The command Get-AzAutomationAccount will not return the sku property, it just returns the Plan.

enter image description here

If you want to get the sku, you could use the command as below.

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

enter image description here