【发布时间】:2021-09-18 23:43:26
【问题描述】:
我想使用 ARM 模板创建一个函数应用,以便 ARM 模板引用现有存储帐户(此模板中的“onestoragebo”),而不是创建新的。贮存。在 ARM 模板下部署时出现以下错误。请帮忙!!
InvalidTemplate - 部署模板验证失败:“模板引用“onestoragebo”无效:找不到具有此名称的模板资源或资源副本。使用详情请参阅https://aka.ms/arm-template-expressions/#reference。'。
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"baseName": {
"defaultValue": "func",
"type": "string",
"metadata": {
"description": "Name use as base-template to named the resources deployed in Azure."
}
},
"funcname": {
"defaultValue": "projectitemedited",
"type": "string",
"metadata": {
"description": "description"
}
},
"storageaccountname": {
"defaultValue": "onestoragebo",
"type": "string",
"metadata": {
"description": "description"
}
}
},
"variables": {
"suffix": "[toLower(resourceGroup().name)]",
"funcAppName": "[toLower(concat(parameters('baseName'),'-', variables('suffix'), '-', parameters('funcname')))]",
"serverFarmName": "[concat('plan', '-', variables('suffix'), '-', substring(parameters('funcname'), 0, min(length(parameters('funcname')),16)))]",
"appInsightsName": "[toLower(concat('appi','-', variables('suffix'),'-', parameters('funcname')))]"
},
"resources": [
{
"type": "Microsoft.Web/sites",
"apiVersion": "2018-11-01",
"name": "[variables('funcAppName')]",
"location": "West Europe",
"kind": "functionapp",
"dependsOn": [
"[resourceId('Microsoft.Web/serverfarms',variables('serverFarmName'))]",
"[parameters('storageaccountname')]"
],
"properties": {
"serverFarmId": "[resourceId('Microsoft.Web/serverfarms', variables('serverFarmName'))]",
"siteConfig": {
"appSettings": [
{
"name": "AzureWebJobsDashboard",
"value": "[concat('DefaultEndpointsProtocol=https;AccountName=', parameters('storageaccountname'), ';AccountKey=', listKeys(parameters('storageaccountname'),'2019-06-01').key1)]"
},
{
"name": "AzureWebJobsStorage",
"value": "[concat('DefaultEndpointsProtocol=https;AccountName=', parameters('storageaccountname'), ';AccountKey=', listKeys(parameters('storageaccountname'),'2019-06-01').key1)]"
},
{
"name": "WEBSITE_CONTENTAZUREFILECONNECTIONSTRING",
"value": "[concat('DefaultEndpointsProtocol=https;AccountName=', parameters('storageaccountname'), ';AccountKey=', listKeys(parameters('storageaccountname'),'2019-06-01').key1)]"
},
{
"name": "WEBSITE_CONTENTSHARE",
"value": "[variables('funcAppName')]"
},
{
"name": "FUNCTIONS_EXTENSION_VERSION",
"value": "~1"
},
{
"name": "FUNCTIONS_WORKER_RUNTIME",
"value": "powershell"
},
{
"name": "APPINSIGHTS_INSTRUMENTATIONKEY",
"value": "[reference(resourceId('microsoft.insights/components/', variables('appInsightsName')), '2015-05-01').InstrumentationKey]"
}
]
},
"httpsOnly": true
}
},
{
"type": "Microsoft.Web/sites/config",
"apiVersion": "2018-11-01",
"name": "[concat(variables('funcAppName'), '/web')]",
"location": "West Europe",
"dependsOn": [
"[resourceId('Microsoft.Web/sites', variables('funcAppName'))]"
],
"properties": {
"ftpsState": "FtpsOnly"
}
},
{
"type": "Microsoft.Web/serverfarms",
"apiVersion": "2018-02-01",
"name": "[variables('serverFarmName')]",
"location": "[resourceGroup().location]",
"sku": {
"name": "Y1",
"tier": "Dynamic"
},
"properties": {
"name": "[variables('serverFarmName')]",
"computeMode": "Dynamic"
}
},
{
"apiVersion": "2015-05-01",
"name": "[variables('appInsightsName')]",
"type": "Microsoft.Insights/components",
"kind": "web",
"location": "[resourceGroup().location]",
"tags": {
"[concat('hidden-link:', resourceGroup().id, '/providers/Microsoft.Web/sites/', variables('funcAppName'))]": "Resource"
},
"properties": {
"Application_Type": "web",
"ApplicationId": "[variables('appInsightsName')]"
}
}
],
"outputs": {
"functionappname": {
"type": "string",
"value": "[variables('funcAppName')]"
}
}
}
【问题讨论】:
标签: azure-functions arm-template azure-storage-account