Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 34 additions & 8 deletions cli/azd/extensions/azure.ai.agents/internal/cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -545,16 +545,42 @@ func (a *InitAction) configureModelChoice(
}

// If the manifest has no model resources, skip the model configuration prompt
// but still ensure subscription and location are set for agent creation
// but still ensure subscription and location are set for agent creation.
// When --project-id is provided, use the existing project to derive location
// and configure Foundry env vars (ACR, AppInsights, etc.) instead of prompting.
if !manifestHasModelResources(agentManifest) {
newCred, err := ensureSubscriptionAndLocation(
ctx, a.azdClient, a.azureContext, a.environment.Name,
"Select an Azure subscription to provision your agent and Foundry project resources.",
)
if err != nil {
return nil, err
if a.flags.projectResourceId != "" {
newCred, err := ensureSubscription(
ctx, a.azdClient, a.azureContext, a.environment.Name,
"Select an Azure subscription to provision your agent and Foundry project resources.",
)
if err != nil {
return nil, err
}
a.credential = newCred

selectedProject, err := selectFoundryProject(
ctx, a.azdClient, a.credential, a.azureContext, a.environment.Name,
a.azureContext.Scope.SubscriptionId, a.flags.projectResourceId,
)
if err != nil {
return nil, err
}

if selectedProject == nil {
return nil, fmt.Errorf("foundry project not found: %s", a.flags.projectResourceId)
}
Comment thread
JeffreyCA marked this conversation as resolved.
} else {
newCred, err := ensureSubscriptionAndLocation(
ctx, a.azdClient, a.azureContext, a.environment.Name,
"Select an Azure subscription to provision your agent and Foundry project resources.",
)
if err != nil {
return nil, err
}
a.credential = newCred
}
a.credential = newCred

return agentManifest, nil
}

Expand Down
Loading