Automation Account Deployment Failed - Model Cannot be null

EE 1 Reputation point
2021-10-15T07:39:54.377+00:00

Hi I am using ARM template provisoning an Automation Account. I don't have enough permission, so when I test to create Automation account from the portal, the 'run as an account' session is grayed out, but I am able to create the account.

However, when I try to provision by ARM template (found it from the MS website), I cannot deploy it, it keeps telling me,
"details": [
{
"code": "BadRequest",
"message": "{\"Message\":\"Model cannot be null.\"}"
}

Is that caused by my permission issue? And what model does it refer to, cannot find anything online yet? Thank you

Azure Automation
Azure Automation
An Azure service that is used to automate, configure, and install updates across hybrid environments.
1,114 questions
{count} votes

2 answers

Sort by: Most helpful
  1. EE 1 Reputation point
    2021-10-15T12:35:44.44+00:00

    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
    "tags": {
    "type": "object",
    "metadata": {
    "description": "An object containing tags that will be applied to the Storage Account"
    }
    },
    "location": {
    "type": "string",
    "metadata": {
    "description": "A valid Azure location (region)"
    }
    },
    "automationAccountSku": {
    "type": "object",
    "metadata": {
    "description": "An object containing the sku details applied to the storage account"
    }
    },
    "automationAccountName": {
    "type": "string",
    "metadata": {
    "description": "Name of the automation account"
    }
    },
    "PowerShellRunbookName": {
    "type": "string",
    "metadata": {
    "description": "Name of the PowerShell Runbook"
    }
    },
    "logResourceGroupName": {
    "type": "string",
    "metadata": {
    "description": "Resource Group that contains the log resources"
    }
    },
    "logStorageAccountName": {
    "type": "string",
    "metadata": {
    "description": "Stroage Account that contains the resource logs"
    }
    },
    "logAnalyticsName": {
    "type": "string",
    "metadata": {
    "description": "Name of the Log Analytics resource"
    }
    }
    },
    "variables": {},
    "resources": [
    {
    "type": "Microsoft.Automation/automationAccounts",
    "apiVersion": "2020-01-13-preview",
    "name": "[parameters('automationAccountName')]",
    "location": "[parameters('location')]",
    "tags": "[parameters('tags')]",
    "identity": {
    "type": "SystemAssigned"
    },
    "properties": {
    "sku": {
    "name": "[parameters('automationAccountSku')]"
    },
    "encryption": {
    "keySource": "Microsoft.Automation",
    "identity": {}
    }
    },
    "resources": [
    {
    "type": "runbooks",
    "apiVersion": "2020-01-13-preview",
    "name": "[parameters('PowerShellRunbookName')]",
    "location": "[parameters('location')]",
    "dependsOn": ["[parameters('automationAccountName')]"],
    "properties": {
    "runbookType": "PowerShell",
    "logProgress": "false",
    "logVerbose": "false"
    }
    }
    ]
    },
    {
    "type": "Microsoft.Automation/automationAccounts/providers/diagnosticSettings",
    "apiVersion": "2017-05-01-preview",
    "name": "[concat(parameters('automationAccountName'), '/Microsoft.Insights/', 'resourceLogs')]",
    "dependsOn": [
    "[resourceId('Microsoft.Automation/automationAccounts', parameters('automationAccountName'))]"
    ],
    "properties": {
    "storageAccountId": "[concat('/subscriptions/',subscription().subscriptionId,'/resourceGroups/',parameters('logResourceGroupName'),'/providers/Microsoft.Storage/storageAccounts/', parameters('logStorageAccountName'))]",
    "workspaceId": "[concat('/subscriptions/',subscription().subscriptionId,'/resourceGroups/',parameters('logResourceGroupName'),'/providers/microsoft.operationalinsights/workspaces/', parameters('logAnalyticsName'))]",
    "logs": [
    {
    "category": "AutomationAccount",
    "enabled": true
    }
    ],
    "metrics": [
    {
    "category": "AllMetrics",
    "enabled": true
    }
    ]
    }
    }
    ]
    }

    0 comments No comments

  2. Stanislav Zhelyazkov 21,101 Reputation points MVP
    2021-10-18T07:10:47.83+00:00

    May be try to remove the part below as I am not sure if you can create runbook without any code.
    When you deploy template you can see on which resource it fails so you can pinpoint to which part of the code is the failure. There is no linking automation account to Log Analytics workspace, you only send logs to Storage account and log analytics workspace. Linking happens trough a resource inside Log Analytics workspace.

    "resources": [
                {
                    "type": "runbooks",
                    "apiVersion": "2020-01-13-preview",
                    "name": "[parameters('PowerShellRunbookName')]",
                    "location": "[parameters('location')]",
                    "dependsOn": [ "[parameters('automationAccountName')]" ],
                    "properties": {
                        "runbookType": "PowerShell",
                        "logProgress": "false",
                        "logVerbose": "false"
                    }
                }
            ]
    
    0 comments No comments