Skip to content

Commit

Permalink
Rollback Azure AI links after provision
Browse files Browse the repository at this point in the history
  • Loading branch information
wbreza committed Apr 29, 2024
1 parent 5aa3844 commit b2a2966
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 50 deletions.
33 changes: 11 additions & 22 deletions cli/azd/internal/cmd/provision.go
Original file line number Diff line number Diff line change
Expand Up @@ -344,30 +344,19 @@ func (p *ProvisionAction) Run(ctx context.Context) (*actions.ActionResult, error
}
}

followUpLinks := []string{
getResourceGroupFollowUp(
ctx,
p.formatter,
p.portalUrlBase,
p.projectConfig,
p.resourceManager,
p.env,
false,
),
}

var additionalLinks map[string]*output.Link

if ok, err := p.env.Config.GetSection("provision.links", &additionalLinks); ok && err == nil {
for _, link := range additionalLinks {
followUpLinks = append(followUpLinks, fmt.Sprintf("%s\n%s", link.Description, output.WithLinkFormat(link.Url)))
}
}

return &actions.ActionResult{
Message: &actions.ResultMessage{
Header: fmt.Sprintf("Your application was provisioned in Azure in %s.", ux.DurationAsText(since(startTime))),
FollowUp: strings.Join(followUpLinks, "\n\n"),
Header: fmt.Sprintf(
"Your application was provisioned in Azure in %s.", ux.DurationAsText(since(startTime))),
FollowUp: getResourceGroupFollowUp(
ctx,
p.formatter,
p.portalUrlBase,
p.projectConfig,
p.resourceManager,
p.env,
false,
),
},
}, nil
}
Expand Down
29 changes: 1 addition & 28 deletions cli/azd/pkg/project/service_target_ai_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"github.com/azure/azure-dev/cli/azd/pkg/ai"
"github.com/azure/azure-dev/cli/azd/pkg/async"
"github.com/azure/azure-dev/cli/azd/pkg/environment"
"github.com/azure/azure-dev/cli/azd/pkg/output"
"github.com/azure/azure-dev/cli/azd/pkg/tools"
)

Expand Down Expand Up @@ -43,33 +42,7 @@ type AiEndpointDeploymentResult struct {

// Initialize initializes the aiEndpointTarget
func (m *aiEndpointTarget) Initialize(ctx context.Context, serviceConfig *ServiceConfig) error {
return serviceConfig.Project.AddHandler(
"postprovision",
func(ctx context.Context, args ProjectLifecycleEventArgs) error {
projectName := m.env.Getenv(AiProjectNameEnvVarName)
aiStudioLink := ai.AzureAiStudioLink(
m.env.GetTenantId(),
m.env.GetSubscriptionId(),
m.env.Getenv(environment.ResourceGroupEnvVarName),
projectName,
)

err := m.env.Config.Set("provision.links.aiStudio", &output.Link{
Name: "Azure AI Studio",
Description: fmt.Sprintf("View the %s project in Azure AI studio:", projectName),
Url: aiStudioLink,
})
if err != nil {
return fmt.Errorf("failed setting aiStudio link: %w", err)
}

if err := m.envManager.Save(ctx, m.env); err != nil {
return fmt.Errorf("failed saving environment: %w", err)
}

return nil
},
)
return nil
}

// RequiredExternalTools returns the required external tools for the machineLearningEndpointTarget
Expand Down

0 comments on commit b2a2966

Please sign in to comment.