You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix Bicep compilation errors preventing azd up/down in AI Gallery template (#400)
This PR resolves critical Bicep compilation errors that were preventing
`azd up` and `azd down` from working, addressing the AI Gallery Standard
Validation failures.
## Issues Fixed
### 1. Critical BCP420 Scope Resolution Error
The main blocker was in `infra/core/host/container-apps.bicep` where a
conditional scope expression was too complex for compile-time
resolution:
```bicep
# Before (causing BCP420 error)
module containerRegistry 'container-registry.bicep' = {
scope: !empty(containerRegistryResourceGroupName) ? resourceGroup(containerRegistryResourceGroupName) : resourceGroup()
# ...
}
# After (split into two modules)
module containerRegistryInCustomRG 'container-registry.bicep' = if (!empty(containerRegistryResourceGroupName)) {
scope: resourceGroup(containerRegistryResourceGroupName)
# ...
}
module containerRegistryInCurrentRG 'container-registry.bicep' = if (empty(containerRegistryResourceGroupName)) {
# ...
}
```
### 2. Safe Access Operator Warnings
Replaced `contains()` function calls with modern safe access operator
(.?) and null coalescing (??):
**storage-account.bicep:**
```bicep
# Before
publicAccess: contains(container, 'publicAccess') ? container.publicAccess : 'None'
# After
publicAccess: container.?publicAccess ?? 'None'
```
**keyvault-secrets.bicep:**
```bicep
# Before
enabled: contains(secret, 'enabled') ? secret.enabled : true
exp: contains(secret, 'exp') ? secret.exp : 0
# After
enabled: secret.?enabled ?? true
exp: secret.?exp ?? 0
```
**cognitiveservices.bicep:**
```bicep
# Before
raiPolicyName: contains(deployment, 'raiPolicyName') ? deployment.raiPolicyName : null
sku: contains(deployment, 'sku') ? deployment.sku : { name: 'Standard', capacity: 20 }
# After
raiPolicyName: deployment.?raiPolicyName ?? null
sku: deployment.?sku ?? { name: 'Standard', capacity: 20 }
```
## Validation Results
- ✅ **Main Bicep template compiles successfully**
- ✅ **All 22 core Bicep modules compile individually**
- ✅ **All 2 app Bicep modules compile individually**
- ✅ **BCP420 and BCP104 errors eliminated**
- ✅ **All use-safe-access warnings resolved**
- ⚠️ **Only 1 warning remains**: secure value warning (acceptable as
parameter is marked `@secure()`)
## Impact
These fixes should resolve the `azd up` and `azd down` failures reported
in the AI Gallery Standard Validation, allowing the template to be
properly deployed and torn down.
Fixes#375.
> [!WARNING]
>
> <details>
> <summary>Firewall rules blocked me from connecting to one or more
addresses</summary>
>
> #### I tried to connect to the following addresses, but was blocked by
firewall rules:
>
> - `aka.ms`
> - Triggering command: `bicep build infra/main.bicep --stdout` (dns
block)
> - Triggering command: `curl -fsSL REDACTED` (dns block)
> - Triggering command: `bicep build --stdout infra/main.bicep` (dns
block)
>
> If you need me to access, download, or install something from one of
these locations, you can either:
>
> - Configure [Actions setup
steps](https://gh.io/copilot/actions-setup-steps) to set up my
environment, which run before the firewall is enabled
> - Add the appropriate URLs or hosts to my [firewall allow
list](https://gh.io/copilot/firewall-config)
>
> </details>
<!-- START COPILOT CODING AGENT TIPS -->
---
💬 Share your feedback on Copilot coding agent for the chance to win a
$200 gift card! Click
[here](https://survey.alchemer.com/s3/8343779/Copilot-Coding-agent) to
start the survey.
---------
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: spboyer <[email protected]>
Co-authored-by: vhvb1989 <[email protected]>
0 commit comments