ARM Template for AZURE API(AZURE BLOB)

%3CLINGO-SUB%20id%3D%22lingo-sub-2247062%22%20slang%3D%22en-US%22%3EARM%20Template%20for%20AZURE%20API(AZURE%20BLOB)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2247062%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20All%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20am%20using%20the%20following%20ARM%20Template%20and%20Parameter%20file%20to%20create%20Multiple%20Azure%20Blob%20api%20connections.%3C%2FP%3E%3CP%3ETo%20access%20the%20storage%20key%20i%20am%20using%20variables%20%22%22storageAccountId%22%3A%20%22%5BresourceId('Microsoft.Storage%2FstorageAccounts'%2C%20parameters('apiconname')%5BcopyIndex(apiconname)%5D.properties.accountName)%5D%22.%20It%20needs%20to%20get%20the%20storage%20account%20name%20from%20the%20paramater%20file%26nbsp%3Bapiconname%20which%20is%20declare%20as%20%22Array%22%20to%20create%20multiple%20connections.%20Now%20the%20problem%20is%20the%20storage%20account%20name%20is%20not%20fetching%20from%20paramater%20file.%20Please%20help%20me%20on%20this.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ETemplate%3A%3C%2FP%3E%3CP%3E%7B%3CBR%20%2F%3E%22%24schema%22%3A%20%22%3CA%20href%3D%22https%3A%2F%2Fschema.management.azure.com%2Fproviders%2FMicrosoft.Logic%2Fschemas%2F2019-08-01%2Fworkflowdefinition.json%23%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fschema.management.azure.com%2Fproviders%2FMicrosoft.Logic%2Fschemas%2F2019-08-01%2Fworkflowdefinition.json%23%3C%2FA%3E%22%2C%3CBR%20%2F%3E%22contentVersion%22%3A%20%221.0.0.0%22%2C%3CBR%20%2F%3E%22parameters%22%3A%20%7B%3CBR%20%2F%3E%22apiconname%22%3A%20%7B%3CBR%20%2F%3E%22type%22%3A%20%22array%22%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%7D%2C%3CBR%20%2F%3E%22variables%22%3A%20%7B%3CBR%20%2F%3E%22copy%22%3A%20%7B%3CBR%20%2F%3E%22name%22%3A%20%22apiconname%22%2C%3CBR%20%2F%3E%22count%22%3A%20%22%5Blength(parameters('apiconname'))%5D%22%3CBR%20%2F%3E%7D%2C%3CBR%20%2F%3E%22storageAccountId%22%3A%20%22%5BresourceId('Microsoft.Storage%2FstorageAccounts'%2C%20parameters('apiconname')%5BcopyIndex(apiconname)%5D.properties.accountName)%5D%22%3CBR%20%2F%3E%7D%2C%3CBR%20%2F%3E%22resources%22%3A%20%5B%3CBR%20%2F%3E%7B%3CBR%20%2F%3E%22type%22%3A%20%22Microsoft.Web%2Fconnections%22%2C%3CBR%20%2F%3E%22apiVersion%22%3A%20%222016-06-01%22%2C%3CBR%20%2F%3E%22name%22%3A%20%22%5Bconcat(parameters('apiconname')%5BcopyIndex()%5D.properties.apiname)%5D%22%2C%3CBR%20%2F%3E%22location%22%3A%20%22eastus%22%2C%3CBR%20%2F%3E%22kind%22%3A%20%22V1%22%2C%3CBR%20%2F%3E%22properties%22%3A%20%7B%3CBR%20%2F%3E%22displayName%22%3A%20%22%5Bconcat(parameters('apiconname')%5BcopyIndex()%5D.properties.displayName)%5D%22%2C%3CBR%20%2F%3E%22customParameterValues%22%3A%20%7B%7D%2C%3CBR%20%2F%3E%22ParameterValues%22%3A%20%7B%3CBR%20%2F%3E%22accountName%22%3A%20%22%5Bconcat(parameters('apiconname')%5BcopyIndex()%5D.properties.accountName)%5D%22%2C%3CBR%20%2F%3E%22accesskey%22%3A%20%22%5BlistKeys(variables('storageAccountId')%2C%20'2019-04-01').keys%5B0%5D.value%5D%22%3CBR%20%2F%3E%7D%2C%3CBR%20%2F%3E%22api%22%3A%20%7B%3CBR%20%2F%3E%22id%22%3A%20%22%5Bconcat(subscription().id%2C'%2Fproviders%2FMicrosoft.Web%2Flocations%2F'%2C%20resourceGroup().location%2C%20'%2FmanagedApis%2F'%2C%20parameters('apiconname')%5BcopyIndex()%5D.properties.api)%5D%22%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%7D%2C%3CBR%20%2F%3E%22copy%22%3A%20%7B%3CBR%20%2F%3E%22name%22%3A%20%22apiconname%22%2C%3CBR%20%2F%3E%22count%22%3A%20%22%5Blength(parameters('apiconname'))%5D%22%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%5D%3CBR%20%2F%3E%7D%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EParamater%20File%3A%3C%2FP%3E%3CP%3E%7B%3CBR%20%2F%3E%22%24schema%22%3A%20%22%3CA%20href%3D%22https%3A%2F%2Fschema.management.azure.com%2Fschemas%2F2015-01-01%2FdeploymentParameters.json%23%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fschema.management.azure.com%2Fschemas%2F2015-01-01%2FdeploymentParameters.json%23%3C%2FA%3E%22%2C%3CBR%20%2F%3E%22contentVersion%22%3A%20%221.0.0.0%22%2C%3CBR%20%2F%3E%22parameters%22%3A%20%7B%3CBR%20%2F%3E%22apiconname%22%3A%20%7B%3CBR%20%2F%3E%22value%22%3A%20%5B%3CBR%20%2F%3E%7B%3CBR%20%2F%3E%22properties%22%3A%20%7B%3CBR%20%2F%3E%22apiname%22%3A%20%22DPAzBlobApi%22%2C%3CBR%20%2F%3E%22displayName%22%3A%20%22DPAzBlobApi%22%2C%3CBR%20%2F%3E%22api%22%3A%20%22AzureBlob%22%2C%3CBR%20%2F%3E%22accountName%22%3A%20%22stoapi%22%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%5D%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%7D%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EError%3A%3C%2FP%3E%3CP%3E%3CSPAN%3EDeployment%20template%20validation%20failed%3A%20'The%20template%20variable%20'storageAccountId'%20is%20not%20valid%3A%20The%20template%20function%20'copyIndex'%20is%20not%20expected%20at%20this%20location.%20The%20function%20can%20only%20be%20used%20in%20a%20resource%20with%20copy%20specified.%20Please%20see%20%3CA%20href%3D%22https%3A%2F%2Faka.ms%2Farm-copy%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Faka.ms%2Farm-copy%3C%2FA%3E%20for%20usage%20details..%20Please%20see%20%3CA%20href%3D%22https%3A%2F%2Faka.ms%2Farm-template-expressions%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Faka.ms%2Farm-template-expressions%3C%2FA%3E%20for%20usage%20details.'.%20(Code%3A%20InvalidTemplate)%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3ERegards%2C%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3EVignesh%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
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