从链接的模板检索Azure SQL的FQDN [英] Retrieve FQDN of Azure SQL from a linkted template

查看:70
本文介绍了从链接的模板检索Azure SQL的FQDN的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm looking for a valid property to retrieve FQDN of a managed Azure SQL server from a deployment of linked template. The one below seems not to be valid

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

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

and where can I find all supported parameters? It seems to be challenging to find enough info from Microsoft Docs.

推荐答案

好像您的链接模板没有名为"fullyQualifiedDomainName"的输出属性.

Looks like your linked template did not have an output property named as 'fullyQualifiedDomainName'.

要从链接的模板获取输出值,请使用语法" [reference('deploymentName').outputs.propertyName.value] "来检索属性值,如此处所述-> https://docs.microsoft.com/zh-CN/azure/azure-resource-manager/resource-group-linked-templates#get-values-from-linked-template

To get an output value from a linked template, retrieve the property value with syntax like "[reference('deploymentName').outputs.propertyName.value]" as explained here -> https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-linked-templates#get-values-from-linked-template

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

Please find below sample parent and linked templates to accomplish your requirement of retrieving FQDN of a managed Azure SQL server.

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

上述两个模板都放置在Storage blob容器中.

Both the above mentioned templates are placed in Storage blob container.

部署:

从部署中检索FQDN的例证:

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

In the above example and illustration, the output property name in linked template is named as "MessageOne" and as we need FQDN of managed Azure SQL server so the value of that "MessageOne" output property is referenced to "fullyQualifiedDomainName".

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

And regarding finding all the supported parameters, one of the easiest ways is to get all the properties of any resource by using 'Get-Member' as shown in below example.

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

Hope this helps!! Cheers!!

这篇关于从链接的模板检索Azure SQL的FQDN的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆