Azure sql database 从链接模板检索Azure SQL的FQDN

Azure sql database 从链接模板检索Azure SQL的FQDN,azure-sql-database,azure-resource-manager,arm-template,Azure Sql Database,Azure Resource Manager,Arm Template,我正在寻找有效属性,以从链接模板的部署检索托管Azure SQL server的FQDN。下面这一条似乎无效 [reference(variables('sqlDeployment')).outputs.fullyQualifiedDomainName.value]" 我在哪里可以找到所有支持的参数?从Microsoft文档中查找足够的信息似乎很有挑战性。您的链接模板似乎没有名为“FullyQualifiedDomain”的输出属性 要从链接模板中获取输出值,请使用以下语法检索属性值:“[re

我正在寻找有效属性,以从链接模板的部署检索托管Azure SQL server的FQDN。下面这一条似乎无效

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

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

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

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

请查找以下示例父级和链接模板,以满足您检索托管Azure SQL server的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]"
        }
    }
}
{
    "$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]"
        }
    }
}
名为“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#",
        "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]"
        }
    }
}
{
    "$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容器中

部署

{
    "$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]"
        }
    }
}
{
    "$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]"
        }
    }
}

从部署中检索FQDN的图示

{
    "$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]"
        }
    }
}
{
    "$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]"
        }
    }
}

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

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

希望这有帮助!!干杯