I'm deploying an ARM template with yaml pipelines using the task AzureResourceManagerTemplateDeployment
with deploymentScope: 'Subscription'
.
I want to deploy a resourcegroup, containing a storageAccounts
and blobServices
. When adding the blobServices
the deployment fails with The resource 'Microsoft.Storage/storageAccounts/mystorageAccountName' is not defined in the template.
I tried different solutions like moving the blobServices
to the storageAccounts.Resources
or removing the dependsOn
section but nothing worked. Any idea how to fix this? This is my current template:
{
"$schema": "https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#",
"contentVersion": "1.0.0.1",
"parameters": {
"rgName": {
"type": "string"
},
"rgLocation": {
"type": "string"
},
"rgtags": {
"type": "object"
}
},
"variables": {
"rgName": "[parameters('rgName')]",
"storageAccountName": "mystorageAccountName"
},
"resources": [
{
"type": "Microsoft.Resources/resourceGroups",
"apiVersion": "2022-09-01",
"location": "[parameters('rgLocation')]",
"name": "[variables('rgName')]",
"properties": {},
"tags": "[parameters('rgtags')]",
"resources": []
},
{
"type": "Microsoft.Resources/deployments",
"apiVersion": "2022-09-01",
"name": "storageDeployment",
"resourceGroup": "[parameters('rgName')]",
"dependsOn": [
"[resourceId('Microsoft.Resources/resourceGroups/', parameters('rgName'))]"
],
"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": "2022-09-01",
"name": "[variables('storageAccountName')]",
"location": "[parameters('rgLocation')]",
"kind": "StorageV2",
"sku": {
"name": "Standard_LRS"
}
},
{
"type": "Microsoft.Storage/storageAccounts/blobServices",
"apiVersion": "2022-09-01",
"name": "[concat(variables('storageAccountName'), '/default')]",
"sku": {
"name": "Standard_LRS",
"tier": "Standard"
},
"dependsOn": [
"[resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName'))]"
]
}
],
"outputs": {}
}
}
}
],
"outputs": {
"deploymentName": {
"type": "string",
"value": "[deployment().name]"
},
"rgName": {
"type": "string",
"value": "[variables('rgName')]"
}
}
}