-
Notifications
You must be signed in to change notification settings - Fork 291
fix: deploy with separate locations for models and other foundry projects #7873
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -654,11 +654,18 @@ func loadAzureContext( | |
| envValueMap[value.Key] = value.Value | ||
| } | ||
|
|
||
| // Use AZURE_AI_DEPLOYMENTS_LOCATION for Scope.Location (used for model filtering). | ||
| // Fall back to AZURE_LOCATION for backward compatibility with older environments. | ||
| location := envValueMap["AZURE_AI_DEPLOYMENTS_LOCATION"] | ||
| if location == "" { | ||
| location = envValueMap["AZURE_LOCATION"] | ||
| } | ||
|
|
||
| return &azdext.AzureContext{ | ||
| Scope: &azdext.AzureScope{ | ||
| TenantId: envValueMap["AZURE_TENANT_ID"], | ||
| SubscriptionId: envValueMap["AZURE_SUBSCRIPTION_ID"], | ||
| Location: envValueMap["AZURE_LOCATION"], | ||
| Location: location, | ||
| }, | ||
| Resources: []string{}, | ||
| }, nil | ||
|
|
@@ -728,7 +735,9 @@ func ensureSubscription( | |
| } | ||
|
|
||
| // ensureLocation prompts for an Azure location if not already set in the AzureContext. | ||
| // Both init flows use this. | ||
| // Both init flows use this. Sets both AZURE_LOCATION (resource group) and | ||
| // AZURE_AI_DEPLOYMENTS_LOCATION (AI/model resources) to the same value as a default. | ||
| // If the user later picks a different model region, only AZURE_AI_DEPLOYMENTS_LOCATION changes. | ||
| func ensureLocation( | ||
| ctx context.Context, | ||
| azdClient *azdext.AzdClient, | ||
|
|
@@ -738,7 +747,8 @@ func ensureLocation( | |
| allowedLocations := supportedRegionsForInit() | ||
|
|
||
| if azureContext.Scope.Location != "" && locationAllowed(azureContext.Scope.Location, allowedLocations) { | ||
| return nil | ||
| // Location already set and valid — ensure AZURE_AI_DEPLOYMENTS_LOCATION is also set | ||
| return setEnvValue(ctx, azdClient, envName, "AZURE_AI_DEPLOYMENTS_LOCATION", azureContext.Scope.Location) | ||
|
Comment on lines
749
to
+751
|
||
| } | ||
| if azureContext.Scope.Location != "" { | ||
| fmt.Printf("%s", output.WithWarningFormat( | ||
|
|
@@ -757,7 +767,11 @@ func ensureLocation( | |
|
|
||
| azureContext.Scope.Location = locationName | ||
|
|
||
| return setEnvValue(ctx, azdClient, envName, "AZURE_LOCATION", azureContext.Scope.Location) | ||
| if err := setEnvValue(ctx, azdClient, envName, "AZURE_LOCATION", azureContext.Scope.Location); err != nil { | ||
| return err | ||
| } | ||
|
|
||
| return setEnvValue(ctx, azdClient, envName, "AZURE_AI_DEPLOYMENTS_LOCATION", azureContext.Scope.Location) | ||
| } | ||
|
|
||
| // ensureSubscriptionAndLocation ensures both subscription and location are set. | ||
|
|
@@ -1085,10 +1099,22 @@ func selectFoundryProject( | |
|
|
||
| selectedProject := projects[selectedIdx] | ||
|
|
||
| // Set location from the selected project | ||
| // Set AI deployments location from the selected project. | ||
| // The project's location determines where AI models and resources are deployed. | ||
| previousLocation := azureContext.Scope.Location | ||
| azureContext.Scope.Location = selectedProject.Location | ||
| if err := setEnvValue(ctx, azdClient, envName, "AZURE_LOCATION", selectedProject.Location); err != nil { | ||
| return nil, fmt.Errorf("failed to set AZURE_LOCATION: %w", err) | ||
| if err := setEnvValue( | ||
| ctx, azdClient, envName, "AZURE_AI_DEPLOYMENTS_LOCATION", selectedProject.Location, | ||
| ); err != nil { | ||
| return nil, fmt.Errorf("failed to set AZURE_AI_DEPLOYMENTS_LOCATION: %w", err) | ||
| } | ||
|
|
||
| // Seed AZURE_LOCATION (resource group location) if not already set. | ||
| // Default to co-locating with the project; user can override before deploying. | ||
| if previousLocation == "" { | ||
| if err := setEnvValue(ctx, azdClient, envName, "AZURE_LOCATION", selectedProject.Location); err != nil { | ||
| return nil, fmt.Errorf("failed to set AZURE_LOCATION: %w", err) | ||
| } | ||
|
Comment on lines
+1102
to
+1117
|
||
| } | ||
|
|
||
| // Configure all Foundry project environment variables | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -83,11 +83,11 @@ func (a *modelSelector) updateEnvLocation(ctx context.Context, selectedLocation | |
|
|
||
| _, err := a.azdClient.Environment().SetValue(ctx, &azdext.SetEnvRequest{ | ||
| EnvName: envName, | ||
| Key: "AZURE_LOCATION", | ||
| Key: "AZURE_AI_DEPLOYMENTS_LOCATION", | ||
| Value: selectedLocation, | ||
| }) | ||
| if err != nil { | ||
| return fmt.Errorf("failed to update AZURE_LOCATION in azd environment: %w", err) | ||
| return fmt.Errorf("failed to update AZURE_AI_DEPLOYMENTS_LOCATION in azd environment: %w", err) | ||
| } | ||
|
|
||
| if a.azureContext == nil { | ||
|
|
@@ -98,7 +98,9 @@ func (a *modelSelector) updateEnvLocation(ctx context.Context, selectedLocation | |
| } | ||
| a.azureContext.Scope.Location = selectedLocation | ||
|
|
||
| fmt.Println(output.WithSuccessFormat("Updated AZURE_LOCATION to '%s' in your azd environment.", selectedLocation)) | ||
| fmt.Println(output.WithSuccessFormat( | ||
| "Updated AZURE_AI_DEPLOYMENTS_LOCATION to '%s' in your azd environment.", selectedLocation, | ||
| )) | ||
|
Comment on lines
84
to
+103
|
||
| return nil | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
loadAzureContextnow prefersAZURE_AI_DEPLOYMENTS_LOCATIONoverAZURE_LOCATION. This is behaviorally significant for model filtering and project selection; there don’t appear to be unit tests covering the precedence/fallback behavior. Consider adding tests for (1) AI var set, (2) only AZURE_LOCATION set (back-compat), and (3) neither set.