Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into wabrez/override-res…
Browse files Browse the repository at this point in the history
…ource-group
  • Loading branch information
ellismg committed May 9, 2024
2 parents f0f7a4a + 567ea64 commit 2fdeddb
Show file tree
Hide file tree
Showing 225 changed files with 10,838 additions and 4,218 deletions.
1 change: 1 addition & 0 deletions .vscode/cspell.misc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,4 @@ overrides:
- myapp
- azdev
- myimage
- azureai
4 changes: 4 additions & 0 deletions cli/azd/.vscode/cspell-azd-dictionary.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ armappconfiguration
armappplatform
armcognitiveservices
armcosmos
armmachinelearning
armresourcegraph
armsql
aspnet
Expand All @@ -42,8 +43,10 @@ azdtest
azfile
azruntime
azsdk
azureai
AZURECLI
azureedge
azureml
azurestaticapps
azuretools
azureutil
Expand Down Expand Up @@ -186,6 +189,7 @@ Syncer
teamcity
testdata
tmpl
toplevel
tracesdk
tracetest
trafficmanager
Expand Down
54 changes: 53 additions & 1 deletion cli/azd/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Release History

## 1.9.0-beta.1 (Unreleased)
## 1.10.0-beta.1 (Unreleased)

### Features Added

Expand All @@ -10,6 +10,58 @@

### Other Changes

## 1.9.0 (2024-05-07)

### Features Added

- [[3718]](https://github.com/Azure/azure-dev/pull/3718) Deploy AI/ML studio online endpoints with host `ml.endpoint`. Starter templates `azd-ai-starter` and `azd-aistudio-starter` are available to get started with ease.
- [[3840]](https://github.com/Azure/azure-dev/pull/3840) Filter templates when running `azd init` or `azd template list` with `--filter`
- .NET Aspire:
- [[3267]](https://github.com/Azure/azure-dev/pull/3267) Support services with multiple exposed ports
- [[3820]](https://github.com/Azure/azure-dev/pull/3820) Container resources now supports reference expressions, and are now modeled the same as project resources

### Bugs Fixed

- [[3822]](https://github.com/Azure/azure-dev/pull/3822) Fix Aspire KeyVault references in manifest files
- [[3858]](https://github.com/Azure/azure-dev/pull/3858) Allow overriding location for Aspire bicep modules

### Other Changes

- [[3821]](https://github.com/Azure/azure-dev/pull/3821) Support running `azd init` in Aspire app host directory
- [[3848]](https://github.com/Azure/azure-dev/pull/3848) Add "Demo Mode" which hides subscription IDs
- [[3828]](https://github.com/Azure/azure-dev/pull/3828) Update Bicep CLI to version 0.26.170.
- [[3800]](https://github.com/Azure/azure-dev/pull/3800) Write ACA Container Manifests in the `infra` directory under the AppHost during `infra synth`.

**Note:** If you had previously used `infra synth`, you will need to move the container app manifests from their old location to the new one for `azd` to use them. If you do not do so, `azd` will generate the default IaC based on your current app host. To do this, move the `containerApp.tmpl.yaml` file in the `manifests` folder under each individual project into an `infra` folder next to the `.csproj` file for your project's Aspire App Host and rename it from `containerApp.tmpl.yaml` to `<name-passed-to-AddProject>.tmpl.yaml` (e.g. `apiserver.tmpl.yaml`, if you write `builder.AddProject<...>("apiserver")`).

## 1.8.2 (2024-04-30)

### Features Added

- [[3804]](https://github.com/Azure/azure-dev/pull/3804) Add user vault storage for development secrets
- [[3755]](https://github.com/Azure/azure-dev/pull/3755) Store `secure()` Bicep parameters outside source tree

### Bugs Fixed

- [[3788]](https://github.com/Azure/azure-dev/pull/3788) Avoid panic in prompting with option details
- [[3796]](https://github.com/Azure/azure-dev/pull/3796) Fix `env refresh` failing when no bicep files are present
- [[3801]](https://github.com/Azure/azure-dev/pull/3801) Fix `azd provision` failing for `.bicepparam` files

### Other Changes

- [[3798]](https://github.com/Azure/azure-dev/pull/3798) Update provider.tf files with skip_provider_registration = "true"

## 1.8.1 (2024-04-23)

### Features Added

- [[3731]](https://github.com/Azure/azure-dev/pull/3731) Support Data Protection Runtime feature for .NET Aspire in ACA under feature flag `azd config set alpha.aspire.autoConfigureDataProtection on`
- [[3715]](https://github.com/Azure/azure-dev/pull/3715) Improved security to prevent committing an environment to the repository

### Bugs Fixed

- [[3748]](https://github.com/Azure/azure-dev/pull/3748) Fix cross-build configuration

## 1.8.0 (2024-04-09)

### Features Added
Expand Down
3 changes: 0 additions & 3 deletions cli/azd/cmd/actions/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ type ResultMessage struct {
// Define the Action outputs.
type ActionResult struct {
Message *ResultMessage

// TraceID is a unique identifier of the end-to-end CLI command execution, that can be used to correlate events in logs.
TraceID string
}

// Action is the representation of the application logic of a CLI command.
Expand Down
28 changes: 4 additions & 24 deletions cli/azd/cmd/auth_login.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,10 +301,6 @@ func (la *loginAction) Run(ctx context.Context) (*actions.ActionResult, error) {
}
}

if err := la.accountSubManager.ClearSubscriptions(ctx); err != nil {
log.Printf("failed clearing subscriptions: %v", err)
}

if err := la.login(ctx); err != nil {
return nil, err
}
Expand All @@ -313,31 +309,15 @@ func (la *loginAction) Run(ctx context.Context) (*actions.ActionResult, error) {
return nil, err
}

// Rehydrate or clear the account's subscriptions cache.
// The caching is done here to increase responsiveness of listing subscriptions (during azd init).
// It also allows an implicit command for the user to refresh cached subscriptions.
if la.flags.clientID == "" {
// Deleting subscriptions on file is very unlikely to fail, unless there are serious filesystem issues.
// If this does fail, we want the user to be aware of this. Like other stored azd account data,
// stored subscriptions are currently tied to the OS user, and not the individual account being logged in,
// this means cross-contamination is possible.
if err := la.accountSubManager.ClearSubscriptions(ctx); err != nil {
return nil, err
}

err := la.accountSubManager.RefreshSubscriptions(ctx)
if err != nil {
// Update the subscriptions cache for regular users (i.e. non-service-principals).
// The caching is done here to increase responsiveness of listing subscriptions in the application.
// It also allows an implicit command for the user to refresh cached subscriptions.
if err := la.accountSubManager.RefreshSubscriptions(ctx); err != nil {
// If this fails, the subscriptions will still be loaded on-demand.
// erroring out when the user interacts with subscriptions is much more user-friendly.
log.Printf("failed retrieving subscriptions: %v", err)
}
} else {
// Service principals do not typically require subscription caching (running in CI scenarios)
// We simply clear the cache, which is much faster than rehydrating.
err := la.accountSubManager.ClearSubscriptions(ctx)
if err != nil {
log.Printf("failed clearing subscriptions: %v", err)
}
}

la.console.Message(ctx, cLoginSuccessMessage)
Expand Down
78 changes: 3 additions & 75 deletions cli/azd/cmd/cobra_builder.go
Original file line number Diff line number Diff line change
@@ -1,24 +1,18 @@
package cmd

import (
"errors"
"fmt"
"log"
"slices"
"strconv"
"strings"

"github.com/Azure/azure-sdk-for-go/sdk/azcore"
"github.com/azure/azure-dev/cli/azd/cmd/actions"
"github.com/azure/azure-dev/cli/azd/cmd/middleware"
"github.com/azure/azure-dev/cli/azd/pkg/azapi"
"github.com/azure/azure-dev/cli/azd/pkg/exec"
"github.com/azure/azure-dev/cli/azd/pkg/input"
"github.com/azure/azure-dev/cli/azd/pkg/ioc"
"github.com/azure/azure-dev/cli/azd/pkg/output"
"github.com/azure/azure-dev/cli/azd/pkg/output/ux"
"github.com/azure/azure-dev/cli/azd/pkg/tools"
"github.com/azure/azure-dev/cli/azd/pkg/tools/azcli"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -122,21 +116,6 @@ func (cb *CobraBuilder) configureActionResolver(cmd *cobra.Command, descriptor *
return err
}

actionName := createActionName(cmd)
var action actions.Action
if err := cmdContainer.ResolveNamed(actionName, &action); err != nil {
if errors.Is(err, ioc.ErrResolveInstance) {
return fmt.Errorf(
//nolint:lll
"failed resolving action '%s'. Ensure the ActionResolver is a valid go function that returns an `actions.Action` interface, %w",
actionName,
err,
)
}

return err
}

runOptions := &middleware.Options{
Name: cmd.Name(),
CommandPath: cmd.CommandPath(),
Expand All @@ -147,65 +126,14 @@ func (cb *CobraBuilder) configureActionResolver(cmd *cobra.Command, descriptor *

// Set the container that should be used for resolving middleware components
runOptions.WithContainer(cmdContainer)

// Run the middleware chain with action
actionResult, err := middlewareRunner.RunAction(ctx, runOptions, action)
actionName := createActionName(cmd)
_, err = middlewareRunner.RunAction(ctx, runOptions, actionName)

// At this point, we know that there might be an error, so we can silence cobra from showing it after us.
cmd.SilenceErrors = true

// TODO: Consider refactoring to move the UX writing to a middleware
invokeErr := cmdContainer.Invoke(func(console input.Console) {
var displayResult *ux.ActionResult
if actionResult != nil && actionResult.Message != nil {
displayResult = &ux.ActionResult{
SuccessMessage: actionResult.Message.Header,
FollowUp: actionResult.Message.FollowUp,
}
} else if err != nil {
displayResult = &ux.ActionResult{
Err: err,
}
}

if displayResult != nil {
console.MessageUxItem(ctx, displayResult)
}

if err != nil {
var respErr *azcore.ResponseError
var azureErr *azapi.AzureDeploymentError
var toolExitErr *exec.ExitError
var suggestionErr *azcli.ErrorWithSuggestion

// We only want to show trace ID for server-related errors,
// where we have full server logs to troubleshoot from.
//
// For client errors, we don't want to show the trace ID, as it is not useful to the user currently.
if errors.As(err, &respErr) ||
errors.As(err, &azureErr) ||
(errors.As(err, &toolExitErr) && toolExitErr.Cmd == "terraform") {
if actionResult != nil && actionResult.TraceID != "" {
console.Message(
ctx,
output.WithErrorFormat(fmt.Sprintf("TraceID: %s", actionResult.TraceID)))
}
}

if errors.As(err, &suggestionErr) {
console.Message(
ctx,
suggestionErr.Suggestion)
}
}

// Stop the spinner always to un-hide cursor
console.StopSpinner(ctx, "", input.Step)
})

if invokeErr != nil {
return invokeErr
}

return err
}

Expand Down
17 changes: 14 additions & 3 deletions cli/azd/cmd/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"github.com/azure/azure-dev/cli/azd/internal/cmd"
"github.com/azure/azure-dev/cli/azd/internal/repository"
"github.com/azure/azure-dev/cli/azd/pkg/account"
"github.com/azure/azure-dev/cli/azd/pkg/ai"
"github.com/azure/azure-dev/cli/azd/pkg/alpha"
"github.com/azure/azure-dev/cli/azd/pkg/auth"
"github.com/azure/azure-dev/cli/azd/pkg/azapi"
Expand Down Expand Up @@ -409,7 +410,7 @@ func registerCommonDependencies(container *ioc.NestedContainer) {
return cloudConfig, nil
}

return nil, &azcli.ErrorWithSuggestion{
return nil, &internal.ErrorWithSuggestion{
Err: err,
Suggestion: fmt.Sprintf(
"Set the cloud configuration by editing the 'cloud' node in the config.json file for the %s environment\n%s",
Expand All @@ -432,7 +433,7 @@ func registerCommonDependencies(container *ioc.NestedContainer) {
if cloud, err := cloud.NewCloud(cloudConfig); err == nil {
return cloud, nil
} else {
return nil, &azcli.ErrorWithSuggestion{
return nil, &internal.ErrorWithSuggestion{
Err: err,
//nolint:lll
Suggestion: fmt.Sprintf("Set the cloud configuration by editing the 'cloud' node in the project YAML file\n%s", validClouds),
Expand All @@ -449,7 +450,7 @@ func registerCommonDependencies(container *ioc.NestedContainer) {
if cloud, err := cloud.NewCloud(value); err == nil {
return cloud, nil
} else {
return nil, &azcli.ErrorWithSuggestion{
return nil, &internal.ErrorWithSuggestion{
Err: err,
Suggestion: fmt.Sprintf("Set the cloud configuration using 'azd config set cloud.name <name>'.\n%s", validClouds),
}
Expand Down Expand Up @@ -607,6 +608,8 @@ func registerCommonDependencies(container *ioc.NestedContainer) {
container.MustRegisterSingleton(npm.NewNpmCli)
container.MustRegisterSingleton(python.NewPythonCli)
container.MustRegisterSingleton(swa.NewSwaCli)
container.MustRegisterScoped(ai.NewPythonBridge)
container.MustRegisterScoped(project.NewAiHelper)

// Provisioning
container.MustRegisterSingleton(infra.NewAzureResourceManager)
Expand All @@ -627,6 +630,7 @@ func registerCommonDependencies(container *ioc.NestedContainer) {
project.AksTarget: project.NewAksTarget,
project.SpringAppTarget: project.NewSpringAppTarget,
project.DotNetContainerAppTarget: project.NewDotNetContainerAppTarget,
project.AiEndpointTarget: project.NewAiEndpointTarget,
}

for target, constructor := range serviceTargetMap {
Expand Down Expand Up @@ -774,3 +778,10 @@ func (w *workflowCmdAdapter) ExecuteContext(ctx context.Context) error {
childCtx := middleware.WithChildAction(ctx)
return w.cmd.ExecuteContext(childCtx)
}

// ArmClientInitializer is a function definition for all Azure SDK ARM Client
type ArmClientInitializer[T comparable] func(
subscriptionId string,
credentials azcore.TokenCredential,
armClientOptions *arm.ClientOptions,
) (T, error)
Loading

0 comments on commit 2fdeddb

Please sign in to comment.