Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nested template inline with resource copy #10

Open
KacperMucha opened this issue Oct 5, 2017 · 9 comments
Open

Nested template inline with resource copy #10

KacperMucha opened this issue Oct 5, 2017 · 9 comments

Comments

@KacperMucha
Copy link

There is a NestedTemplateInline.json template which can be used also for cross resource group deployments in your repo. It even has a copyIndex() usage example, but it uses property copy iteration.

I have a template in which I want to do cross resource group deployment and inside the inline template I moved resources that were deployed using resource iteration method (earlier they were in root template and deployment worked), but when I try to deploy it I get error message - "...Microsoft.Resources/deployments... The template function 'copyIndex' is not expected at this location. The function can only be used in a resource with copy specified." Is it a bug or by design? Because it looks like only property copy syntax is allowed in nested inline template. But I have some resources and a bunch of alerts configured inside the nested template, so I can't use property iteration syntax.

@KacperMucha
Copy link
Author

I've found another strange issue. ListKeys function also seems to not work in nested template. For example, Azure Function default template contains this code:

{
    "name": "AzureWebJobsDashboard",
    "value": "[concat('DefaultEndpointsProtocol=https;AccountName=',parameters('storageName'),';AccountKey=',listKeys(resourceId('Microsoft.Storage/storageAccounts', parameters('storageName')), '2015-05-01-preview').key1)]"
},

And it perfectly works in root a template, but in nested template I get an error:
The Resource 'Microsoft.Storage/storageAccounts/somestorageaccount' under resource group 'RG' was not found.
It looks like dependsOn defined on Function resource is ignored and listKeys tries to execute before storage account is created.

@abhi1509
Copy link

abhi1509 commented Feb 2, 2018

did you find an answer/workaround to this ?

@KacperMucha
Copy link
Author

Yeah, I stopped using nested inline templates.

@wahidsaleemi
Copy link

Having the same problem myself.

@rkuehfus
Copy link

This still seems to be an issue using even the latest API - 2018-05-01

@tyconsulting
Copy link

I worked around the issue by looping outside of the nested template

@tapasudenia
Copy link

tapasudenia commented Mar 28, 2019

Did you find any workaround to this? I have this piece of resource which I want to iterate couple of times
The code below is part of the master template, I use the template link (citrix-connector-vm.json) which, actually creates a VM
{
"name": "[concat('CreateConnector',copyIndex(),uniqueString(resourceGroup().id))]",
"type": "Microsoft.Resources/deployments",
"apiVersion": "2017-05-10",
"dependsOn": [
"[resourceId('Microsoft.Compute/availabilitySets', variables('connAvailailitySetName'))]"
],
"properties": {
"mode": "Incremental",
"templateLink": {
"uri": "[concat(uri(deployment().properties.templateLink.uri,'citrix-connector-vm.json'),parameters('SasToken'))]",
"contentVersion": "1.0.0.0"
},
"parameters": {
"virtualNetworkName": {
"value": "[parameters('virtualNetworkName')]"
},
"adSubnetName": {
"value": "[parameters('adSubnetName')]"
},
"connAvailabilitySetName": {
"value": "[variables('connAvailailitySetName')]"
},
"connVmName": {
"value": "[concat(variables('connVMName'), copyIndex())]"
},
"connVmIp": {
"value": "10.3.0.7"
},
"connAdminUsername": {
"value": "[parameters('connAdminUsername')]"
},
"connAdminPassword": {
"value": "[parameters('connAdminPassword')]"
},
"connVmSize": {
"value": "[parameters('connVmSize')]"
},
"connDiskType": {
"value": "[parameters('connDiskType')]"
},
"connImageSKU": {
"value": "[parameters('connImageSKU')]"
}
}
},
"copy": {
"name": "CopyConnectorVM",
"count": "[parameters('numberOfConnectors')]",
"mode": "Serial",
"batchSize":1
}
}

@JackStromberg
Copy link

Sorry to bump up an older topic, but I can repro this issue with the copy function and nested templates as well.

@hsubramaniam
Copy link

Anything on this yet?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants