2017-07-25 156 views
1

我正在爲Azure自動化創建和ARM模板並希望上傳自定義模塊。下面的例子我看到它上傳了一個公共模塊,給出了模塊的URL。我如何修改它,以便它使用我的自定義模塊。如何將自定義模塊添加到ARM模板

"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]" 
         } 
        } 
       } 

回答

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

相關問題