Azure / Azure/bicep-types-az

front door rule

Open
#2,200 0 comments 0 reactions 0 assignees View on GitHub
inaccuracy
Dominant language
TypeScript
Stars
108
Forks
44
Avg merge
18h 53m
Merged PRs (30d)
29

Description

### Resource Type

Microsoft.Cdn/profiles/ruleSets

### Api Version

2023-05-01

### Issue Type

Resource fails to deploy

### Other Notes

I'm trying to deploy a rule belonging to a rule set, which in turn belongs to a front door profile as a separate bicep module.
but I get the following error

Deployment template validation failed: 'The template resource '[format('{0}/{1}/{2}', split(parameters('ruleSetName'), '/')[0], split(parameters('ruleSetName'), '/')[1], parameters('name'))]' at line '1' and column '1216' is not valid: The language expression property array index '1' is out of bounds.. Please see https://aka.ms/arm-functions for usage details.'. (Code: InvalidTemplate)

### Bicep Repro

**frontdoor-rule-set.bicep**
```bicep
param name string
param profileName string

resource frontDoor 'Microsoft.Cdn/profiles@2021-06-01' existing = {
name:profileName
}
resource ruleSet 'Microsoft.Cdn/profiles/ruleSets@2023-05-01' = {
name: name
parent: frontDoor
}

output name string = ruleSet.name
```
**frontdoor-rule.bicep**
```bicep
param ruleSetName string
param name string
param action object
param condition object

resource ruleSet 'Microsoft.Cdn/profiles/ruleSets@2023-05-01' existing = {
name: ruleSetName
}

resource rule 'Microsoft.Cdn/profiles/ruleSets/rules@2023-05-01' = {
name: name
parent: ruleSet
properties: {
actions: [
action
]
conditions: [
condition
]
}
}
```
**mani.bicep**
```bicep
module ruleSet 'services/frontdoor-rule-set.bicep' = {
name:'fd-rs-${envName}'
params:{
name:frontDoorRulSetName
profileName:frontDoorProfile.outputs.name
}
}

module rule 'services/frontdoor-rule.bicep' = {
name:'fd-rule-${envName}'
params:{
name:frontDoorRuleName
ruleSetName:ruleSet.outputs.name
action: {
name: 'RouteConfigurationOverride'
parameters: {
originGroupOverride: {
forwardingProtocol: 'MatchRequest'
originGroup: {
id: graphicDownloadRoute.outputs.originGroupId
}
}
typeName: 'DeliveryRuleRouteConfigurationOverrideActionParameters'
}
}
condition: {
name: 'UrlPath'
parameters: {
matchValues: [
'hashcode'
'sas'
'systeminfos'
]
negateCondition: false
operator: 'Contains'
transforms: [
'Lowercase'
]
typeName: 'DeliveryRuleUrlPathMatchConditionParameters'
}
}
}
}
```
### Confirm

- [X] I have read the troubleshooting guide and looked for duplicates.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with frontdoor-rule-set.bicep, frontdoor-rule.bicep, and mani.bicep, then reproduce the deployment template validation error for Microsoft.Cdn/profiles/ruleSets/rules@2023-05-01. Trace how ruleSet.outputs.name is used when the rule resource is declared. Done means the separate rule-set and rule modules deploy successfully without the array-index error.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure
Domain
cloud, infrastructure
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.