Skip to content

Commit

Permalink
Improve Developer CLI error handling for prerequisites and Azure subs…
Browse files Browse the repository at this point in the history
…cription validation (#665)

### Summary & Motivation

Fix an issue in the Developer CLI where missing prerequisites (e.g.,
NodeJS) resulted in the CLI exiting without any error message. The CLI
now correctly identifies missing prerequisites and displays an error
such as: `NodeJS of minimum version 25.3.0 should be installed.`

Additionally, a validation has been added to the
`configure-continuous-deployments` CLI command to ensure that the
selected Azure subscriptions for staging and production belong to the
same tenant, preventing configuration errors.

### Checklist

- [x] I have added tests, or done manual regression tests
- [x] I have updated the documentation, if necessary
  • Loading branch information
tjementum authored Jan 5, 2025
2 parents 9df2486 + c29c826 commit 3afc8ac
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,14 @@ private void SelectAzureSubscriptions()
Config.StagingSubscription = SelectSubscription("Staging");
Config.ProductionSubscription = SelectSubscription("Production");

if(Config.StagingSubscription.TenantId != Config.ProductionSubscription.TenantId)
{
AnsiConsole.MarkupLine($"[red]ERROR:[/] Please select two subscriptions from the same tenant, and try again.");
Environment.Exit(1);
}

RunAzureCliCommand($"""account set --subscription "{Config.StagingSubscription.Id}" """);

return;

Subscription SelectSubscription(string environmentName)
Expand Down
3 changes: 2 additions & 1 deletion developer-cli/Installation/Prerequisite.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ protected override bool IsValid()
Arguments = Command,
RedirectStandardOutput = true,
RedirectStandardError = true
}
},
exitOnError: false
);

var possibleFileLocations = checkOutput.Split(Environment.NewLine);
Expand Down

0 comments on commit 3afc8ac

Please sign in to comment.