如何将自定义模块添加到ARM模板

时间:2017-07-25 14:07:16

标签: azure azure-resource-manager arm-template

我正在为Azure Automation创建和ARM模板,并希望上传自定义模块。下面的例子我看到它上传了一个公共模块,给出了模块的URL。如何修改它以使其占用我的自定义模块。

"resources": [
                {
                    "name": "[concat(parameters('automationAccountName'), '/', variables('dscModules').xNetworking.ModuleName)]",
                    "type": "microsoft.automation/automationAccounts/Modules",
                    "apiVersion": "[variables('automationApiVersion')]",
                    "tags": {},
                    "dependsOn": [
                        "[concat('Microsoft.Automation/automationAccounts/', parameters('automationAccountName'))]"
                    ],
                    "properties": {
                        "contentLink": {
                            "uri": "[variables('dscModules').xNetworking.ModuleUri]"
                        }
                    }
                }

1 个答案:

答案 0 :(得分:0)

请参阅此blog:Deploy Custom Azure Automation Integration Modules Using ARM Templates。您可以使用以下模板将自定义模块部署到Azure自动化帐户。

{
  "$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')]"
          }
        }
      }
    }
  ]
}

参数应该在下面,只是一个例子:

$parameters = @{
    'moduleName' = 'myModule'
    'moduleUri' = 'https://github.com/rchaganti/armseries/raw/master/MyModule.zip'
    'automationAccountName' = 'shuitest'
    'automationAccountType' = 'Existing'
    'TemplateFile' = 'D:\xuexi\automation.json'
}

注意:您可以从this获得templatelink

另外,您可以参考此answer