diff --git a/cli/azd/extensions/azure.ai.agents/internal/cmd/init.go b/cli/azd/extensions/azure.ai.agents/internal/cmd/init.go index 71587ae8d84..456086be442 100644 --- a/cli/azd/extensions/azure.ai.agents/internal/cmd/init.go +++ b/cli/azd/extensions/azure.ai.agents/internal/cmd/init.go @@ -755,10 +755,13 @@ func (a *InitAction) parseAndSetProjectResourceId(ctx context.Context) error { }, }) if err != nil { - fmt.Printf("failed to prompt for connection selection: %v\n", err) - } else { - selectedConnection = &appInsightsConnections[int(*selectResp.Value)] + return fmt.Errorf("prompting for Application Insights connection selection: %w", err) } + selectedConnection = &appInsightsConnections[int(*selectResp.Value)] + } + + if selectedConnection.Credentials.Key == "" { + return fmt.Errorf("Application Insights connection '%s' has no credentials key", selectedConnection.Name) } if err := a.setEnvVar(ctx, "APPLICATIONINSIGHTS_CONNECTION_STRING", selectedConnection.Credentials.Key); err != nil {