我收到一个错误:
“部署参数'appServiceName'的值为空。”
即使在通过parametersLink
获取的文件中定义了它。从来没有提示我,所以应该为null,但是为什么从没有提示我?如何正确地将参数从parametersLink
文件传递到templateLink
?
主模板:
{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"rgName": {
"type": "string",
"metadata": {
"description": "Resource Group required in which to create App Service"
}
}
},
"variables": {},
"resources": [
{
"name": "LinkedAppServiceTemplate",
"type": "Microsoft.Resources/deployments",
"apiVersion": "2017-05-10",
"resourceGroup": "[parameters('rgName')]",
"properties": {
"mode": "Incremental",
"templateLink": {
"uri": "uri_to_template_file",
"contentVersion": "1.0.0.0"
},
"parametersLink": {
"uri": "uri_to_params_file",
"contentVersion": "1.0.0.0"
}
}
}
]
}
链接模板:
{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {},
"variables": {},
"resources": [
{
"name": "[parameters('appServiceName')]",
"type": "Microsoft.Web/serverfarms",
"apiVersion": "2015-05-01",
"location": "[parameters('rgLocation')]"
}
]
}
链接参数:
{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"appServiceName": {
"metadata": {
"description": "Name of the App Service to be created"
}
},
"rgLocation": {
"defaultValue": "eastus",
"metadata": {
"description": "Location of the resource group to be created"
}
}
}
}
答案 0 :(得分:0)
您需要在称为链接模板的文件中定义参数:
遵循tutorial on how to create linked templates,因为它还将向您展示如何将参数从主模板传递到链接模板。
在这种情况下,您的链接模板需要在parameters对象中声明参数。
"parameters": {
"appServiceName" : {
"type": "string",
"metadata" : {
"description": "This parameter needs to exist to pass from the link file"
}
}
}