Azure / Azure/azure-quickstart-templates
reference function vs. condition clause
- Dominant language
- Bicep
- Stars
- 14.9k
- Forks
- 16.2k
- Avg merge
- 6d 21h
- Merged PRs (30d)
- 6
Description
Is this a bug that reference function is evaluated before condition clause?
Expected behavior:
When variables('resource_deployKusto') is true: Kusto cluster is created(in other resource cell) and evaluate the rest of this resource
When variables('resource_deployKusto') is false: Kusto cluster is **NOT** created(in other resource cell) and evaluate nothing of this resource
Actual behavior:
When variables('resource_deployKusto') is false: Kusto cluster is NOT created(in other resource cell) and got failure when deploy this resource because kusto cluster wass not found.
```
{
"condition": "[variables('resource_deployKusto')]",
"type": "Microsoft.Authorization/roleAssignments",
"apiVersion": "[variables('resource_roleAssignment_APIVersion')]",
"name": "[guid(concat(subscription().id, parameters('resource_roleAssignment_name'), 'Kusto2SA_contributor', resourceId('Microsoft.Storage/storageAccounts', parameters('resource_storageAccount_name'))))]",
"dependsOn": [
"[resourceId('Microsoft.Kusto/Clusters', parameters('resource_name'))]"
],
"scope": "[resourceId('Microsoft.Storage/storageAccounts', parameters('resource_storageAccount_name'))]",
"properties": {
"principalId": "[reference(resourceId('Microsoft.Kusto/Clusters', parameters('resource_name')), variables('resource_kustoApiVersion'), 'Full').identity.principalId]",
"principalType": "[parameters('resource_roleAssignment_principalType')]",
"roleDefinitionId": "[concat(subscription().id, '/providers/Microsoft.Authorization/roleDefinitions/', parameters('resource_roleAssignment_roleId_SBDC'))]"
}
},
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the shown Microsoft.Authorization/roleAssignments resource and examine its condition, dependsOn, and reference(resourceId(...)) expressions for both values of resource_deployKusto. Reproduce the deployment using the provided template fragment; done means determining whether the observed evaluation order is a bug and documenting the supported behavior or required change.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure
- Domain
- cloud
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100