gpt4 book ai didi

azure - parametersLink 选项不将参数传递给 templateLink

转载 作者:行者123 更新时间:2023-12-03 04:16:36 25 4
gpt4 key购买 nike

我收到错误:

"The value of deployment parameter 'appServiceName' is null."

即使它是在通过 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"
}
}
}
}

最佳答案

您需要在称为链接模板的文件中定义参数:

关注tutorial on how to create linked templates因为它还将向您展示如何将参数从主模板传递到链接模板。

在这种情况下,您的链接模板需要在参数对象中进行参数声明。

"parameters": {
"appServiceName" : {
"type": "string",
"metadata" : {
"description": "This parameter needs to exist to pass from the link file"
}
}
}

关于azure - parametersLink 选项不将参数传递给 templateLink,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52451511/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com