从链接模板中检索 Azure SQL 的 FQDN
Retrieve FQDN of Azure SQL from a linkted template
我正在寻找一个有效的 属性 来从链接模板的部署中检索托管 Azure SQL 服务器的 FQDN。下面那个好像无效
[reference(variables('sqlDeployment')).outputs.fullyQualifiedDomainName.value]"
我在哪里可以找到所有支持的参数?从 Microsoft Docs 中找到足够的信息似乎具有挑战性。
您的链接模板似乎没有名为 'fullyQualifiedDomainName' 的输出 属性。
要从链接模板获取输出值,请使用类似“[reference('deploymentName').outputs.propertyName.value][= 的语法检索 属性 值49=]" 如此处解释 -> https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-linked-templates#get-values-from-linked-template
请在下面找到示例父模板和链接模板,以完成检索托管 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]"
}
}
}
上述两个模板都放在 Storage blob 容器中。
部署:
从部署中检索 FQDN 的图示:
在上面的示例和插图中,链接模板中的输出 属性 名称被命名为 "MessageOne",因为我们需要托管 Azure SQL 服务器的 FQDN,所以该值"MessageOne" 输出 属性 被引用到 "fullyQualifiedDomainName".
关于查找所有受支持的参数,最简单的方法之一是使用 'Get-Member' 获取任何资源的所有属性,如下例所示。
希望对您有所帮助!!干杯!!
我正在寻找一个有效的 属性 来从链接模板的部署中检索托管 Azure SQL 服务器的 FQDN。下面那个好像无效
[reference(variables('sqlDeployment')).outputs.fullyQualifiedDomainName.value]"
我在哪里可以找到所有支持的参数?从 Microsoft Docs 中找到足够的信息似乎具有挑战性。
您的链接模板似乎没有名为 'fullyQualifiedDomainName' 的输出 属性。
要从链接模板获取输出值,请使用类似“[reference('deploymentName').outputs.propertyName.value][= 的语法检索 属性 值49=]" 如此处解释 -> https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-linked-templates#get-values-from-linked-template
请在下面找到示例父模板和链接模板,以完成检索托管 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]"
}
}
}
上述两个模板都放在 Storage blob 容器中。
部署:
从部署中检索 FQDN 的图示:
在上面的示例和插图中,链接模板中的输出 属性 名称被命名为 "MessageOne",因为我们需要托管 Azure SQL 服务器的 FQDN,所以该值"MessageOne" 输出 属性 被引用到 "fullyQualifiedDomainName".
关于查找所有受支持的参数,最简单的方法之一是使用 'Get-Member' 获取任何资源的所有属性,如下例所示。
希望对您有所帮助!!干杯!!