【发布时间】:2021-01-10 05:35:23
【问题描述】:
我需要通过 ARM 模板存储帐户创建 --> 文件共享 --> 带有挂载文件共享的容器。
依赖关系是:
- 文件共享取决于存储帐户
- 容器依赖于文件共享
如何获取文件共享的ReferenceId?
我有以下代码:
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"storageAccountType": {
"type": "string",
"defaultValue": "Standard_LRS",
"allowedValues": [
"Standard_LRS",
"Standard_GRS"
],
"metadata": {
"description": "Storage account type (SKU)"
}
},
"fileShareName": {
"type": "string",
"minLength": 3,
"maxLength": 63,
"defaultValue": "sftp",
"metadata": {
"description": "Name of the File Share to be created. "
}
}
},
"variables": {
"deploymentLocation": "[resourceGroup().location]",
"storageAccountName": "[concat('sftpstr', uniqueString(resourceGroup().id))]"
},
"resources": [
{
"type": "Microsoft.Storage/storageAccounts",
"name": "[variables('storageAccountName')]",
"apiVersion": "2019-06-01",
"location": "[variables('deploymentLocation')]",
"sku": {
"name": "[parameters('storageAccountType')]"
},
"kind": "StorageV2",
"properties": {
"accessTier": "Hot"
}
},
{
"type": "Microsoft.Storage/storageAccounts/fileServices/shares",
"apiVersion": "2019-06-01",
"properties": {
"accessTier": "Hot"
},
"name": "[concat(variables('storageAccountName'), '/default/', parameters('fileShareName'))]",
"dependsOn": [
"[resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName'))]"
]
},
{
"type": "Microsoft.ContainerInstance/containerGroups",
"name": "sftp-container-group",
"apiVersion": "2018-04-01",
"dependsOn": [
"[resourceId('Microsoft.Storage/storageAccounts/fileServices/shares', ????? )]" //how to get reference to specific Fileshare??? I've tried > [concat(variables('storageAccountName'), '/default/', parameters('fileShareName'))] but it didn't work
],
"properties": {
.......
}
}
]
}
我不知道如何设置对 Fileshare 的依赖:
"dependsOn": [
"[resourceId('Microsoft.Storage/storageAccounts/fileServices/shares', ????? )]" //how to get reference to specific Fileshare???
],
我试过[concat(variables('storageAccountName'), '/default/', parameters('fileShareName'))],但没用。
有什么想法吗?
谢谢
【问题讨论】:
-
只需尝试将文件共享的名称改为“?????”在
dependsOn块中。 -
@CharlesXu 我做到了,但没用。我收到验证错误
Deployment template validation failed: 'The template resource 'sftp-container-group' is not valid: Unable to evaluate template language function 'resourceId': the type 'Microsoft.Storage/storageAccounts/fileServices/shares' requires '3' resource name argument(s).
标签: azure dependencies azure-resource-manager arm-template fileshare