Skip to content

Conversation

@davidfowl
Copy link
Member

Description

Use the new interaction service to prompt in the dashboard for subscription id and location.

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • No
  • Does the change make any security assumptions or guarantees?
    • No
  • Does the change require an update in our Aspire docs?

Improve user prompt for Azure subscription settings in provisioning context

Update Azure subscription prompt to include HTML link for creating a free account
@github-actions github-actions bot added the area-integrations Issues pertaining to Aspire Integrations packages label Jun 25, 2025
@davidfowl davidfowl added this to the 9.4 milestone Jul 9, 2025
@eerhardt eerhardt self-assigned this Jul 10, 2025
new InteractionInput { InputType = InputType.SecretText, Label = "Subscription ID", Placeholder = "Select Subscription ID", Required = true },
new InteractionInput { InputType = InputType.Text, Label = "Resource Group", Value = "GetResourceGroupDefault"},
],
new InputsDialogInteractionOptions { ShowDismiss = false, EnableMessageMarkdown = true },
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be possible to dismiss, allowing users to interact with the dashboard and other resources still.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is possible.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The dialog looks like this:

image

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you also query for subscription ids?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can, but doing that would prevent me from entering in something that isn't in the list. I plan on openining an interaction service feature request tomorrow to support an input that allows both a list of options and the ability to enter in a free form value.

Without this, do you think for 9.4 we should leave it as-is without the list? Or should we query the for the list and show it if we found some (preventing entering something that isn't in the list)?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are values remembered? A checkbox was added to the parameters dialog for that.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eerhardt yes we need to save them to user secrets

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It auto persists to user secrets, which I think is a good default (all of the other azure state does as well).

Copy link
Member Author

@davidfowl davidfowl Jul 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eerhardt lets update the link to description to point to an aka.ms link. We can remove the Azure free account link and just use one that points to the docs.

cc @IEvangelist

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It auto persists to user secrets, which I think is a good default (all of the other azure state does as well).

At one point I had a checkbox (which defaulted to true), but I removed it. My reasoning was because if you didn't save the information, when you added another Azure resource on a new run, you would get prompted again and if you choose a different Resource Group, or subscription, you'd get into a weird torn state where some resources were in one location/resourcegroup/sub and some where in another.

I think it is better to just always save the information. So you can't get into this state as easy.

- Save data to user secrets
{
while (_options.Location == null || _options.SubscriptionId == null)
{
var locations = typeof(AzureLocation).GetProperties(BindingFlags.Public | BindingFlags.Static)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to do this more than once ever?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tg-msft Why do we need to reflect for this? Is there another way?

cc @vhvb1989

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At least it is public reflection - and not the private reflection you had originally. 😆

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like you should first prompt for subscription, and then from a subscription you can get the list of locations:

var armClient = new ArmClient(credential);

// Get the subscription (replace with your actual subscription ID)
var subscription = await armClient.GetDefaultSubscriptionAsync();

// List all locations (regions) available for this subscription
await foreach (var location in subscription.GetLocationsAsync())
{
    Console.WriteLine($"{location.Name} - {location.DisplayName}");
}

eerhardt added 3 commits July 11, 2025 14:20
Need to refactor InteractionResult to allow for mocking without using IVT.
@eerhardt eerhardt marked this pull request as ready for review July 11, 2025 21:03
@eerhardt
Copy link
Member

I believe this is ready for review now. FYI - @davidfowl @JamesNK

I had to make some changes to the public API of InteractionResult since it isn't possible to test users of the InteractionService without using IVT.

@davidfowl
Copy link
Member Author

👍🏾 ship it

EnableMessageMarkdown = true,
ValidationCallback = static (validationContext) =>
{
var subscriptionInput = validationContext.Inputs[1];
Copy link
Member

@JamesNK JamesNK Jul 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of referencing inputs by index, you could create them earlier and assign them to variables, use the variable in the array passed to PromptInputsAsync and here in the validation. The instance will be the same. It's non-obvious that you can do that.

Although I'm starting to wonder if inputs should have a name and be accessible via name here and in the result...

Keep referencing by index and in 9.5 I'll change the API to make inputs a KeyedCollection.

Comment on lines +119 to +122
if (!IsValidResourceGroupName(resourceGroupInput.Value))
{
validationContext.AddValidationError(resourceGroupInput, "Resource group name must be a valid Azure resource group name.");
}
Copy link
Member

@JamesNK JamesNK Jul 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't say why the name isn't valid. It's not a good user experience.

await validationCallback(context).ConfigureAwait(false);

return context.HasErrors;
return !context.HasErrors;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this a bug?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep

@davidfowl davidfowl merged commit ab40bf0 into main Jul 12, 2025
276 checks passed
@davidfowl davidfowl deleted the davidfowl/prompt-azure-config branch July 12, 2025 01:06
@davidfowl
Copy link
Member Author

/backport to release/9.4

@github-actions
Copy link
Contributor

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-integrations Issues pertaining to Aspire Integrations packages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants