@@ -173,7 +173,17 @@ func (p *FoundryProvisioningProvider) Initialize(
173173 )
174174 }
175175 if endpoint != "" {
176- warnNetworkIgnoredInBrownfield (rawYAML , svcName )
176+ if err := warnNetworkIgnoredInBrownfield (
177+ rawYAML ,
178+ projectPath ,
179+ svcName ,
180+ ); err != nil {
181+ return exterrors .Validation (
182+ exterrors .CodeInvalidAzureYaml ,
183+ fmt .Sprintf ("resolve Foundry service configuration: %s" , err ),
184+ "fix the project service configuration in azure.yaml" ,
185+ )
186+ }
177187 p .brownfieldEndpoint = endpoint
178188 if err := p .captureBrownfieldDeployments (ctx , rawYAML , svcName ); err != nil {
179189 return err
@@ -194,7 +204,17 @@ func (p *FoundryProvisioningProvider) Initialize(
194204 case errors .Is (err , synthesis .ErrEndpointBrownfield ):
195205 // endpoint: reuse — connect to the existing project, skip provisioning.
196206 // network: has no effect in brownfield mode; warn if both are present.
197- warnNetworkIgnoredInBrownfield (rawYAML , svcName )
207+ if err := warnNetworkIgnoredInBrownfield (
208+ rawYAML ,
209+ projectPath ,
210+ svcName ,
211+ ); err != nil {
212+ return exterrors .Validation (
213+ exterrors .CodeInvalidAzureYaml ,
214+ fmt .Sprintf ("resolve Foundry service configuration: %s" , err ),
215+ "fix the project service configuration in azure.yaml" ,
216+ )
217+ }
198218 endpoint , endpointErr := foundryServiceEndpointAtRoot (
199219 rawYAML ,
200220 projectPath ,
@@ -286,23 +306,46 @@ func (p *FoundryProvisioningProvider) networkEnvMap(ctx context.Context) map[str
286306// warnNetworkIgnoredInBrownfield logs a warning when a service declares both
287307// endpoint: (brownfield) and network:. The account's network posture is fixed
288308// by whoever created it, so the network: block has no effect.
289- func warnNetworkIgnoredInBrownfield (rawYAML []byte , svcName string ) {
309+ func warnNetworkIgnoredInBrownfield (
310+ rawYAML []byte ,
311+ projectRoot string ,
312+ svcName string ,
313+ ) error {
290314 type svc struct {
291315 Endpoint string `yaml:"endpoint,omitempty"`
292316 Network yaml.Node `yaml:"network,omitempty"`
293317 }
294318 type root struct {
295- Services map [string ]svc `yaml:"services"`
319+ Services map [string ]map [ string ] any `yaml:"services"`
296320 }
297321 var r root
298322 if err := yaml .Unmarshal (rawYAML , & r ); err != nil {
299- return
323+ return err
324+ }
325+ values := r .Services [svcName ]
326+ if values == nil {
327+ return nil
328+ }
329+ if projectRoot != "" {
330+ resolved , err := foundry .ResolveFileRefs (values , projectRoot )
331+ if err != nil {
332+ return err
333+ }
334+ values = resolved
300335 }
301- s := r .Services [svcName ]
302- if strings .TrimSpace (s .Endpoint ) != "" && ! s .Network .IsZero () {
336+ data , err := yaml .Marshal (values )
337+ if err != nil {
338+ return err
339+ }
340+ var service svc
341+ if err := yaml .Unmarshal (data , & service ); err != nil {
342+ return err
343+ }
344+ if strings .TrimSpace (service .Endpoint ) != "" && ! service .Network .IsZero () {
303345 log .Printf ("[warn] foundry provider: service %q sets both endpoint: and network:; " +
304346 "network: is ignored in brownfield mode (the account's network posture is fixed)" , svcName )
305347 }
348+ return nil
306349}
307350
308351// or infra/main.bicep exists under p.projectPath. Stat-only.
0 commit comments