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

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

问题描述

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

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

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

解决方案

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

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

从部署中检索 FQDN 的说明:

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

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

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

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]"

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

解决方案

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

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

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

Parent template named as "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]"
        }
    }
}

Linked template named as "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]"
        }
    }
}

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

Deployment:

Illustration of retrieval of FQDN from the deployment:

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".

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天全站免登陆