【问题标题】:Retrieve FQDN of Azure SQL from a linkted template从链接模板中检索 Azure SQL 的 FQDN
【发布时间】:2019-03-08 19:22:14
【问题描述】:

我正在寻找一个有效的属性来从链接模板的部署中检索托管 Azure SQL 服务器的 FQDN。下面的似乎无效

[reference(variables('sqlDeployment')).outputs.fullyQualifiedDomainName.value]"

在哪里可以找到所有支持的参数?从 Microsoft Docs 中找到足够的信息似乎具有挑战性。

【问题讨论】:

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


    【解决方案1】:

    您的链接模板似乎没有名为“fullyQualifiedDomainName”的输出属性。

    要从链接模板中获取输出值,请使用类似“[reference('deploymentName').outputs.propertyName.value]”的语法检索属性值,如此处所述 -> @987654321 @

    请在下面找到示例父模板和链接模板,以完成检索托管 Azure SQL 服务器的 FQDN 的要求。

    父模板命名为“parenttemplate.json”

    {
        "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
        "contentVersion": "1.0.0.0",
        "parameters": {
            "location": {
                "type": "string",
                "defaultValue": "[resourceGroup().location]",
                "metadata": {
                  "description": "Location for all resources."
                }
            }
        },
        "variables": {
            "sqlserverName": "gttestsqlserver",
            "sqlAdministratorLogin": "gttestuser",
            "sqlAdministratorLoginPassword": "gttestpassword2#",
            "sqlDeployment": "linkedTemplate"
        },
        "resources": [
          {
            "apiVersion": "2017-05-10",
            "name": "[variables('sqlDeployment')]",
            "type": "Microsoft.Resources/deployments",
            "properties": {
              "mode": "Incremental",
              "templateLink": {
                "uri": "[uri(deployment().properties.templateLink.uri, 'linkedtemplate.json')]",
                "contentVersion": "1.0.0.0"
              }
            }
          }
        ],
        "outputs": {
            "messageFromLinkedTemplate": {
                "type": "string",
                "value": "[reference(variables('sqlDeployment')).outputs.MessageOne.value]"
            }
        }
    }
    

    链接模板命名为“linkedtemplate.json”

    {
        "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
        "contentVersion": "1.0.0.0",
        "parameters": {
            "location": {
                "type": "string",
                "defaultValue": "[resourceGroup().location]",
                "metadata": {
                  "description": "Location for all resources."
                }
            }
        },
        "variables": {
            "sqlserverName": "gttestsqlserver",
            "sqlAdministratorLogin": "gttestuser",
            "sqlAdministratorLoginPassword": "gttestpassword2#"
        },
        "resources": [
            {
                "name": "[variables('sqlserverName')]",
                "type": "Microsoft.Sql/servers",
                "location": "[parameters('location')]",
                "tags": {
                  "displayName": "gttestsqlserver"
                },
                "apiVersion": "2014-04-01",
                "properties": {
                    "administratorLogin": "[variables('sqlAdministratorLogin')]",
                    "administratorLoginPassword": "[variables('sqlAdministratorLoginPassword')]",
                    "version": "12.0"
                }
            }
        ],
        "outputs": {
            "MessageOne": {
                "type" : "string",
                "value": "[reference(variables('sqlserverName')).fullyQualifiedDomainName]"
            }
        }
    }
    

    上述两个模板都放置在存储 blob 容器中。

    部署

    从部署中检索 FQDN 的图示

    在上面的示例和插图中,链接模板中的输出属性名称被命名为“MessageOne”,因为我们需要托管 Azure SQL 服务器的 FQDN,因此“MessageOne”输出属性的值被引用为“fullyQualifiedDomainName”。

    关于查找所有支持的参数,最简单的方法之一是使用“Get-Member”获取任何资源的所有属性,如下例所示。

    希望这会有所帮助!!干杯!!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-01-11
      • 2017-06-07
      • 2012-12-01
      相关资源
      最近更新 更多