Say-HelloSample.json

{
    "$schema": "http://schemas.microsoft.org/azure/deploymentTemplate?api-version=2015-01-01-preview#",
    "contentVersion": "1.0",
    "parameters": {
        "accountName": {
            "type": "string",
            "metadata": {
                "description": "The name of the Azure Automation account to deploy to."
            }
        },
        "regionId": {
            "type": "string",
            "allowedValues": [
                "Japan East",
                "East US 2",
                "West Europe",
                "Southeast Asia",
                "South Central US"
            ],
            "metadata": {
                "description": "The region to deploy the Automation account in."
            }
        },
        "credentialName": {
            "defaultValue": "MyCred",
            "type": "string",
            "metadata": {
                "description": "DefaultAzureCredential is the name of the Automation credential used in this runbook. This credential allows you to authenticate to Azure. ",
                "resource": "MyCred"
            }
        },
        "userName": {
            "type": "string",
            "metadata": {
                "description": "The username for the Azure Automation credential."
            }
        },
        "password": {
            "type": "string",
            "metadata": {
                "description": "The password for the Azure Automation credential."
            }
        },
        "variableValue": {
            "type": "string",
            "defaultValue": "Beth",
            "metadata": {
                "description": "The value for the variable. In this case, a string value."
            }
        }
 
    },
    "variables": {
        "runbookName": "Say-HelloSample",
        "scriptUri": "https://storage123abc.blob.core.windows.net/containerpublic/Say-HelloSample.ps1",
        "runbookDescription": "Runbook says hello",
        "sku": "Free",
        "variableName":"MyNameVariable"
    },
    "resources": [
        {
            "name": "[parameters('accountName')]",
            "type": "Microsoft.Automation/automationAccounts",
            "apiVersion": "2015-01-01-preview",
            "location": "[parameters('regionId')]",
            "dependsOn": [],
            "tags": {},
            "properties": {
                "sku": {
                    "name": "[variables('sku')]"
                }
            },
            "resources": [
                {
                    "name": "[variables('runbookName')]",
                    "type": "runbooks",
                    "apiVersion": "2015-01-01-preview",
                    "location": "[parameters('regionId')]",
                    "dependsOn": [
                        "[concat('Microsoft.Automation/automationAccounts/', parameters('accountName'))]"
                    ],
                    "tags": {},
                    "properties": {
                        "runbookType": "Script",
                        "logProgress": "false",
                        "logVerbose": "false",
                        "description": "[variables('runbookDescription')]",
                        "publishContentLink": {
                            "uri": "[variables('scriptUri')]",
                            "version": "1.0.0.0"
                        }
                    }
                },
                {
                    "name": "[parameters('credentialName')]",
                    "type": "credentials",
                    "apiVersion": "2015-01-01-preview",
                    "location": "[parameters('regionId')]",
                    "dependsOn": [
                        "[concat('Microsoft.Automation/automationAccounts/', parameters('accountName'))]"
                    ],
                    "tags": {},
                    "properties": {
                        "userName": "[parameters('userName')]",
                        "password": "[parameters('password')]"
                    }
                },
       
                {
                    "name": "[variables('variableName')]",
                    "type": "variables",
                    "apiVersion": "2015-01-01-preview",
                    "location": "[parameters('regionId')]",
                    "dependsOn": [
                        "[concat('Microsoft.Automation/automationAccounts/', parameters('accountName'))]"
                    ],
                    "tags": {
                    },
                    "properties": {
                        "description": "",
                        "isEncrypted": 0,
                        "type": "string",
                        "value": "[concat('\"', parameters('variableValue'),'\"')]"
                    }
                }
 
            ]
        }
    ],
    "outputs": {}
}