Arm模板的DependsOn函数对嵌套模板的工作方式是否有所不同?
interface CustomTemplateRepository<S> {
fun <E: S> save(entity: E): E
fun <E: S> saveAndFlush(entity: E): E
}
class TemplateRepositoryImpl(
private val jdbcTemplate: NamedParameterJdbcTemplate,
@PersistenceContext private val entityManager: EntityManager
) : CustomTemplateRepository<Template> {
override fun <E : Template> save(entity: E): E {
if(entity.id == null)
entity.id = jdbcTemplate.queryForObject("select nextval('sequence_generator')",
mutableMapOf<String, Any>(), Long::class.java)
entityManager.persist(entity)
return entity
}
override fun <E : Template> saveAndFlush(entity: E): E {
return save(entity).also {
entityManager.flush()
}
}
}
我尝试了以下组合,但都失败了
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"location": {
"type": "string",
"defaultValue": "eastus2",
"metadata": {
"description": "Location for all resources."
}
},
"appBaseName": {
"type": "string",
"metadata": {
"description": "Name of the application. Used in the name of resources."
},
"minLength": 5,
"maxLength": 12
}
},
"variables": {
"ResourceGroupName": "[concat(parameters('appBaseName'), '-rg')]",
"storageAccountName": "[tolower(concat('stg',parameters('appBaseName')))]",
"WebAppName": "[concat(parameters('appBaseName'), '-web')]",
"AppServicePlanName": "[concat(parameters('appBaseName'), '-ASP')]"
},
"resources": [
{
"type": "Microsoft.Resources/resourceGroups",
"apiVersion": "2019-10-01",
"name": "[variables('ResourceGroupName')]",
"location": "[parameters('location')]",
"properties": {}
},
{
"name": "nesteddeploymentstorage",
"type": "Microsoft.Resources/deployments",
"apiVersion": "2018-05-01",
"resourceGroup": "[variables('ResourceGroupName')]",
"dependsOn": [
"[resourceId('Microsoft.Resources/resourceGroups/', variables('ResourceGroupName'))]"
],
"properties": {
"mode": "Incremental",
"template": {
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
},
"variables": {},
"resources": [
{
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "2019-06-01",
"name": "[variables('storageAccountName')]",
"location": "[parameters('location')]",
"sku": {
"name": "Standard_LRS",
"tier": "Standard"
},
"kind": "StorageV2",
"properties": {
"accessTier": "Hot"
}
},
{
"name": "[variables('AppServicePlanName')]",
"type": "Microsoft.Web/serverfarms",
"apiVersion": "2018-02-01",
"kind": "functionapp",
"location": "[parameters('location')]",
"tags": {},
"dependsOn": [
],
"properties": {
"name": "[variables('AppServicePlanName')]",
"perSiteScaling": false,
"reserved": false,
"targetWorkerCount": 0,
"targetWorkerSizeId": 0
},
"sku": {
"name": "Y1",
"tier": "Dynamic",
"size": "Y1",
"family": "Y",
"capacity": 0
}
},
{
"name": "[variables('WebAppName')]",
"type": "Microsoft.Web/sites",
"apiVersion": "2018-02-01",
"kind": "functionapp",
"location": "[parameters('location')]",
"dependsOn": [
"[resourceId('Microsoft.Storage/storageAccounts/', variables('storageAccountName'))]",
"[resourceId('Microsoft.Web/serverfarms/', variables('AppServicePlanName'))]"
],
"properties": {
"serverFarmId": "[resourceId('Microsoft.Web/serverfarms/', variables('AppServicePlanName'))]",
"reserved": false,
"siteConfig": {
"use32BitWorkerProcess": false,
"appSettings": [
]
},
"clientAffinityEnabled": false,
"clientCertEnabled": false,
"hostNamesDisabled": false,
"containerSize": 1536,
"dailyMemoryTimeQuota": 0,
"httpsOnly": false
},
"resources": []
}
]
}
}
}
],
"outputs": {}
}
我不能在部署模板中将变量与resourceId一起使用吗?我应该担心什么限制或技巧吗?是否必须使用纯文本而不是params或var?