2016-03-30 56 views
1

我正在嘗試爲Automation Runbook創建一個Webhook。到目前爲止,我已經實現了以下內容:使用ARM模板創建Azure自動化Runbook Webhook?

  1. 創建自動化帳戶
  2. 創建運行手冊

下面是我使用的模板:

"resources": [ 
    { 
     "name": "[parameters('accountName')]", 
     "type": "Microsoft.Automation/automationAccounts", 
     "apiVersion": "2015-10-31", 
     "location": "[parameters('location')]", 
     "dependsOn": [ ], 
     "tags": { }, 
     "properties": { 
      "sku": { 
       "name": "[parameters('sku')]" 
      } 
     }, 
     "resources": [ 
      { 
       "name": "[variables('runbookName')]", 
       "type": "runbooks", 
       "apiVersion": "2015-10-31", 
       "location": "[parameters('location')]", 
       "dependsOn": [ 
        "[concat('Microsoft.Automation/automationAccounts/', parameters('accountName'))]" 
       ], 
       "tags": { }, 
       "properties": { 
        "runbookType": "Script", 
        "logProgress": "false", 
        "logVerbose": "false", 
        "publishContentLink": { 
         "uri": "https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/101-automation-runbook-getvms/Runbooks/Get-AzureVMTutorial.ps1", 
         "version": "1.0.0.0" 
        }, 
        "webhook": { 
         "name": "test" 
        } 
       } 
       ,"resources": [ 
        { 
         "apiVersion": "2015-10-31", 
         "type": "webhooks", 
         "name": "testwebhook", 
         "dependsOn": [ 
          "[concat('Microsoft.Automation/automationAccounts/', parameters('accountName'), '/runbooks/', variables('runbookName'))]" 
         ] 
        } 
       ] 
      }, 
      { 
       "name": "[parameters('credentialName')]", 
       "type": "credentials", 
       "apiVersion": "2015-10-31", 
       "location": "[parameters('location')]", 
       "dependsOn": [ 
        "[concat('Microsoft.Automation/automationAccounts/', parameters('accountName'))]" 
       ], 
       "tags": { }, 
       "properties": { 
        "userName": "[parameters('userName')]", 
        "password": "[parameters('password')]" 
       } 
      } 
     ] 
    } 
] 

我不是能夠創建一個webhook。到目前爲止,搜索之後,我也找不到用於創建Runbook的模板模式。任何幫助表示讚賞。

在此先感謝

回答

1

你不應該把網絡掛接的運行手冊的資源內,因爲網絡掛接屬於自動化帳戶,而不是運行手冊。下面是一個示例:

"resources": [ 
    { 
     "name": "[parameters('accountName')]", 
     "type": "Microsoft.Automation/automationAccounts", 
     "apiVersion": "2015-10-31", 
     "location": "[parameters('location')]", 
     "dependsOn": [ ], 
     "tags": { }, 
     "properties": { 
      "sku": { 
       "name": "[parameters('sku')]" 
      } 
     }, 
     "resources": [ 
      { 
       "name": "[variables('runbookName')]", 
       "type": "runbooks", 
       "apiVersion": "2015-10-31", 
       "location": "[parameters('location')]", 
       "dependsOn": [ 
        "[concat('Microsoft.Automation/automationAccounts/', parameters('accountName'))]" 
       ], 
       "tags": { }, 
       "properties": { 
        "runbookType": "Script", 
        "logProgress": "false", 
        "logVerbose": "false", 
        "publishContentLink": { 
         "uri": "https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/101-automation-runbook-getvms/Runbooks/Get-AzureVMTutorial.ps1", 
         "version": "1.0.0.0" 
        }, 
        "webhook": { 
         "name": "test" 
        } 
       } 
       ,"resources": [ 

       ] 
      }, 
      { 
       "apiVersion": "2015-10-31", 
       "type": "webhooks", 
       "name": "testwebhook", 
       "dependsOn": [ 
        "[concat('Microsoft.Automation/automationAccounts/', parameters('accountName'))]", 
        "[concat('Microsoft.Automation/automationAccounts/', parameters('accountName'), '/runbooks/', variables('runbookName'))]" 
       ], 
       "properties": { 
        "isEnabled": true, 
        "runbook": { 
         "name": "[variables('runbookName')]" 
        } 
       } 
      }, 
      { 
       "name": "[parameters('credentialName')]", 
       "type": "credentials", 
       "apiVersion": "2015-10-31", 
       "location": "[parameters('location')]", 
       "dependsOn": [ 
        "[concat('Microsoft.Automation/automationAccounts/', parameters('accountName'))]" 
       ], 
       "tags": { }, 
       "properties": { 
        "userName": "[parameters('userName')]", 
        "password": "[parameters('password')]" 
       } 
      } 
     ] 
    } 
] 

上面的模板測試後,我得到以下信息:

New-AzureRmResourceGroupDeployment : 9:35:31 AM - Resource Microsoft.Automation/automationAccounts/webhooks 'automationARMtest/testwebhook' failed with message '{"Message":"Invalid Uri"}' 
At line:1 char:1 
+ New-AzureRmResourceGroupDeployment -name automationARMtest -ResourceG ... 
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    + CategoryInfo   : NotSpecified: (:) [New-AzureRmResourceGroupDeployment], Exception 
    + FullyQualifiedErrorId : Microsoft.Azure.Commands.Resources.NewAzureResourceGroupDeploymentCommand 

至於什麼@ElizabethCooper低於所述,網絡掛接尚未在ARM模板支持。我已經提交了功能請求。請投票here

+1

自動化目前不支持ARM模板中的webhooks。如果您可以爲自動化團隊提交此功能的反饋請求以進行跟蹤,那將是非常好的。 https://feedback.azure.com/forums/246290-automation –

相關問題