我的场景:
我在 github(AUri、BUri、CUri)中托管了三个运行手册(A、B 和 C)。我正在使用 ARM 模板来创建自动化帐户、凭据、三个运行手册,然后使用其中一个(运行手册 C)创建一个作业。
Runbook C 是主要的,A 和 B 在 C 内部被调用。
问题是要从 C 调用 A 和 B,它们需要首先发布。
有没有办法通过我当前的 ARM 模板直接发布它们?
一种解决方法是将我的所有代码压缩到 Runbook C 中,但我更喜欢将它们分开。
到目前为止的代码:
{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
.......
},
"variables": {
........
},
"resources": [
{
"name": "[parameters('accountName')]",
"apiVersion": "2015-10-31",
"type": "Microsoft.Automation/AutomationAccounts",
"location": "westeurope",
"properties": {
"sku": {
"name": "Basic"
}
},
"resources": [
{
"apiVersion": "2015-10-31",
"dependsOn": [
"[concat('Microsoft.Automation/automationAccounts/', parameters('accountName'))]"
],
"location": "westeurope",
"name": "[variables('A')]",
"properties": {
"runbookType": "Script",
"logProgress": "false",
"logVerbose": "false",
"description": "[variables('runbookDescription')]",
"publishContentLink": {
"uri": "[variables('AUri')]",
"version": "1.0.0.0"
}
},
"type": "runbooks"
},
{
"apiVersion": "2015-10-31",
"dependsOn": [
"[concat('Microsoft.Automation/automationAccounts/', parameters('accountName'))]"
],
"location": "westeurope",
"name": "[variables('B')]",
"properties": {
"runbookType": "Script",
"logProgress": "false",
"logVerbose": "false",
"description": "[variables('runbookDescription')]",
"publishContentLink": {
"uri": "[variables('BUri')]",
"version": "1.0.0.0"
}
},
"type": "runbooks"
},
{
"apiVersion": "2015-10-31",
"dependsOn": [
"[concat('Microsoft.Automation/automationAccounts/', parameters('accountName'))]"
],
"location": "westeurope",
"name": "[variables('C')]",
"properties": {
"runbookType": "Script",
"logProgress": "false",
"logVerbose": "false",
"description": "[variables('runbookDescription')]",
"publishContentLink": {
"uri": "[variables('CUri')]",
"version": "1.0.0.0"
}
},
"type": "runbooks"
},
{
"name": "[parameters('credentialName')]",
"type": "credentials",
"apiVersion": "2015-10-31",
"location": "westeurope",
"dependsOn": [
"[concat('Microsoft.Automation/automationAccounts/', parameters('accountName'))]"
],
"tags": { },
"properties": {
"userName": "[parameters('userName')]",
"password": "[parameters('password')]"
}
}
//optional code that runs the runbook created, yo need unique Guid value for "name" key
,
{
"name": "Unique GUID Here",
"type": "jobs",
"apiVersion": "2015-10-31",
"location": "westeurope",
"dependsOn": [
"[concat('Microsoft.Automation/automationAccounts/', parameters('accountName'))]",
"[concat('Microsoft.Automation/automationAccounts/', parameters('accountName'), '/credentials/', parameters('credentialName'))]",
"[concat('Microsoft.Automation/automationAccounts/', parameters('accountName'), '/runbooks/',variables('A'))]",
"[concat('Microsoft.Automation/automationAccounts/', parameters('accountName'), '/runbooks/',variables('B'))]",
"[concat('Microsoft.Automation/automationAccounts/', parameters('accountName'), '/runbooks/',variables('C'))]"
],
"tags": {
"key": "value"
},
"properties": {
"runbook": {
"name": "[variables('C')]"
}
}
} ]
}