3

Currently I am uploading manually custom modules for azure runtime automation runbooks in the azure portal. Then I also create manually a runbook which executes my custom module. I would like to do this via an ARM script.

I assume everything you can do in the azure portal, is also possible in ARM.

I am new to ARM, but deployed a website through ARM. That was relatively easy as I could just select Web App as resource. But in the Add Resource list, I can't find anything related to runbook or modules. Where can I find templates for this?

Shui shengbao
  • 18,746
  • 3
  • 27
  • 45
1408786user
  • 1,868
  • 1
  • 21
  • 39

1 Answers1

3

It is possible. You could check this link: Deploy Custom Azure Automation Integration Modules Using ARM Templates.

{
  "$schema": "http://schemas.microsoft.org/azure/deploymentTemplate?api-version=2015-01-01-preview#",
  "contentVersion": "1.0",
  "parameters": {
    "automationAccountType": {
      "type": "string",
      "allowedValues": [
        "New",
        "Existing"
      ]
    },
    "automationAccountName": {
      "type": "string"
    },
    "moduleName": {
      "type": "string"
    },
    "moduleUri":{
      "type": "string"  
    }
  },
  "variables": {
    "templatelink": "[concat('https://raw.githubusercontent.com/rchaganti/armseries/master/', parameters('automationAccountType'), 'AccountTemplate.json')]"
  },
  "resources": [
    {
      "apiVersion": "2015-01-01",
      "name": "nestedTemplate",
      "type": "Microsoft.Resources/deployments",
      "properties": {
        "mode": "incremental",
        "templateLink": {
          "uri": "[variables('templatelink')]",
          "contentVersion": "1.0"
        },
        "parameters": {
          "accountName": {
            "value": "[parameters('automationAccountName')]"
          },
          "accountLocation": {
            "value": "[resourceGroup().Location]"
          },
          "moduleName": {
            "value": "[parameters('moduleName')]"
          },
          "moduleUri": {
            "value": "[parameters('moduleUri')]"
          }
        }
      }
    }
  ]
}
Shui shengbao
  • 18,746
  • 3
  • 27
  • 45
  • "templatelink": "[concat('https://devopsgallerystorage.blob.core.windows.net/azureautomationpackages/templates%5Corigtemplates%5C', parameters('automationAccountType'), 'AccountTemplate.json')]" What should I use here as template link? I get everytime an error telling me the template link is invalid. – 1408786user May 16 '17 at 14:11
  • 2
    The original nested template link is not available. I updated the post with right JSON. This now follows the same method as the PowerShell gallery to deploy modules to AA. Check the updated post: http://www.powershellmagazine.com/2015/11/26/deploy-custom-azure-automation-integration-modules-using-arm-templates/ – ravikanth May 17 '17 at 04:47
  • @ravikanth Thank you very much. `"templatelink": "[concat('https://raw.githubusercontent.com/rchaganti/armseries/master/', parameters('automationAccountType'), 'AccountTemplate.json')]"` works for me. – Shui shengbao May 17 '17 at 05:18
  • Is it also possible to do it without the external github url? I actually don't want my service to depend on an external dependency. It also looks like the param ModuleUri is not accepting a local file source. {\\\"module.properties.contentLink.uri\\\":[\\\"The uri field is not a valid fully-qualified http, https, or ftp URL.\\\"]}} My Uri: "ModuleUri": { "value": "file://C:/Source/MyModule.zip" } – 1408786user May 18 '17 at 08:20
  • 2
    @user1408786 Based on my knowledge, it is not possible. it could not be a local file. It supports https and http. I suggest you could save your module on Azure storage account if it is necessary. – Shui shengbao May 18 '17 at 08:35
  • 2
    Yup! The portal uploads the local zip to a temp location and deploys it. Doing it directly from a local source in a template based deployment is not possible. – ravikanth May 18 '17 at 09:06
  • Thanks. Is it also possible to not use the templatelink? So just in case the template gets removed or updated or anything, my ARM project still works. – 1408786user May 18 '17 at 09:09
  • @ravikanth Is it also possible to not use the templatelink? So just in case the template gets removed or updated or anything, my ARM project still works. – Shui shengbao May 18 '17 at 09:09
  • @user1408786 You had better @ ravikanth. He is the of the blog and a PowerShell expert. – Shui shengbao May 18 '17 at 09:12
  • @user1408786 Yes, it is possible. Take a look at https://github.com/rchaganti/armseries. You will see newautomationaccount.json and existingautomationaccount.json. Save them to your storage account. – Shui shengbao May 19 '17 at 01:02