ARM Template for AZURE API(AZURE BLOB)

Brass Contributor

Hi All,

 

I am using the following ARM Template and Parameter file to create Multiple Azure Blob api connections.

To access the storage key i am using variables ""storageAccountId": "[resourceId('Microsoft.Storage/storageAccounts', parameters('apiconname')[copyIndex(apiconname)].properties.accountName)]". It needs to get the storage account name from the paramater file apiconname which is declare as "Array" to create multiple connections. Now the problem is the storage account name is not fetching from paramater file. Please help me on this.

 

Template:

{
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2019-08-01/workflowdefinition....",
"contentVersion": "1.0.0.0",
"parameters": {
"apiconname": {
"type": "array"
}
},
"variables": {
"copy": {
"name": "apiconname",
"count": "[length(parameters('apiconname'))]"
},
"storageAccountId": "[resourceId('Microsoft.Storage/storageAccounts', parameters('apiconname')[copyIndex(apiconname)].properties.accountName)]"
},
"resources": [
{
"type": "Microsoft.Web/connections",
"apiVersion": "2016-06-01",
"name": "[concat(parameters('apiconname')[copyIndex()].properties.apiname)]",
"location": "eastus",
"kind": "V1",
"properties": {
"displayName": "[concat(parameters('apiconname')[copyIndex()].properties.displayName)]",
"customParameterValues": {},
"ParameterValues": {
"accountName": "[concat(parameters('apiconname')[copyIndex()].properties.accountName)]",
"accesskey": "[listKeys(variables('storageAccountId'), '2019-04-01').keys[0].value]"
},
"api": {
"id": "[concat(subscription().id,'/providers/Microsoft.Web/locations/', resourceGroup().location, '/managedApis/', parameters('apiconname')[copyIndex()].properties.api)]"
}
},
"copy": {
"name": "apiconname",
"count": "[length(parameters('apiconname'))]"
}
}
]
}

 

Paramater File:

{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"apiconname": {
"value": [
{
"properties": {
"apiname": "DPAzBlobApi",
"displayName": "DPAzBlobApi",
"api": "AzureBlob",
"accountName": "stoapi"
}
}
]
}
}
}

 

Error:

Deployment template validation failed: 'The template variable 'storageAccountId' is not valid: The template function 'copyIndex' is not expected at this location. The function can only be used in a resource with copy specified. Please see https://aka.ms/arm-copy for usage details.. Please see https://aka.ms/arm-template-expressions for usage details.'. (Code: InvalidTemplate)

 

Regards,

Vignesh

 

 

 

0 Replies