【问题标题】:Reference an existing Azure Automation Account in a different Resource Group引用不同资源组中的现有 Azure 自动化帐户
【发布时间】:2017-07-09 03:10:28
【问题描述】:

我需要使用 ARM 模板中的现有 Azure 自动化帐户来创建新的编译作业。当自动化帐户位于我正在部署的同一资源组中时,我知道如何执行此操作,但我无法弄清楚它何时是不同资源组中的现有自动化帐户。

例如:

父模板(资源)

{
  "name": "dscCompile",
  "type": "Microsoft.Resources/deployments",
  "apiVersion": "2016-09-01",
  "dependsOn": [
    "[resourceId('Microsoft.Resources/deployments', 'newGuid')]"
  ],
  "properties": {
    "mode": "Incremental",
    "templateLink": {
      "uri": "[variables('templates').dsc]",
      "contentVersion": "1.0.0.0"
    },
    "parameters": {
      "compile-settings": {
        "value": {
          "configurationData": "[concat('{\"AllNodes\": [{\"NodeName\":\"*\",\"PSDscAllowPlainTextPassword\":true,\"RetryIntervalSec\":30,\"RetryCount\":20},{\"Nodename\":\"localhost\",\"domainName\":\"', parameters('extn-settings').domain, '\",\"adminCreds\":\"', parameters('adminPassword'), '\",\"Role\":\"DC\"}]}')]",
          "configurationName": "createPDC",
          "location": "Australia Southeast",
          "name": "[reference('newGuid').outputs.guid.value)]"
        }
      },                    
      "tag-values": {
        "value": "[parameters('tag-values')]"
      }
    }
 }

子模板

$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "compile-settings": {
            "type": "object",
            "metadata": {
                "description": "These are settings for a DSC Compile"
            }
        },
        "tag-values": {
            "type": "object",
            "metadata": {
                "description": "These are the Tag values"
            }
        }
    },
    "resources": [
        {
            "name": "[parameters('compile-settings').jobGuid]",
            "type": "Microsoft.Automation/automationAccounts/compilationjobs",
            "apiVersion": "2015-10-31",
            "location": "[parameters('compile-settings').location]",
            "tags": "[parameters('tag-values')]",
            "dependsOn": [],
            "properties": {
                "configuration": {
                    "name": "[parameters('compile-settings').configurationName]"
                },
                "parameters": {
                    "ConfigurationData": "[parameters('compile-settings').ConfigurationData]"
                }
            },
            "resources": []
        }       
    ],
    "outputs": {}
}

提前致谢!

【问题讨论】:

  • 那么编译作业的代码在哪里呢?我真的不明白你想要达到什么目的。入职不会以任何方式引用资源组。所以它不需要。
  • 抱歉 - 我发布了一些我不认识的代码。我已经更正了 - 对此感到抱歉。
  • 顺便说一句,你能给我一个链接到如何使用模板开始编译作业的示例吗? (带参数),谢谢!
  • 我看到了,但我说的是你传入的编译设置对象(你可以用虚假的值替换值,但如果是复杂对象,请保留结构)跨度>

标签: azure arm-template


【解决方案1】:

好的,直到最近才可能做到这一点,您可以通过 cross resource group deployment 做到这一点。

基本上,您在模板(也称为嵌套\子模板)中创建一个模板并选择不同的资源组(使用该模板的resourceGroup 属性。别无他法。

{
    "apiVersion": "2017-05-10",
    "name": "nestedTemplate",
    "type": "Microsoft.Resources/deployments",
    "resourceGroup": "crossResourceGroupDeployment",
    "properties": { }
}

【讨论】:

  • 好的 - 我让它在我的部署中工作,但父部署的 api 版本也需要更改为“2017-05-10”。我发现的另一件事是 VSTS 中的资源组部署任务使用较旧的 API 版本,我的发布失败。
  • 是的 - 我知道......你的建议很有效。谢谢你的帮助。只需要找到VSTS无法识别新API的解决方案
猜你喜欢
  • 2020-07-28
  • 2021-06-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-04-30
  • 2021-09-06
  • 2022-01-17
  • 2022-11-10
相关资源
最近更新 更多