Skip to content

function keys in aca draft #9938

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

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft

Conversation

brettsam
Copy link

@brettsam brettsam commented Jun 18, 2025

@github-actions github-actions bot added the area-integrations Issues pertaining to Aspire Integrations packages label Jun 18, 2025
@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Jun 18, 2025
/// <summary>
/// Gets the collection of keys associated with the Azure Functions resource.
/// </summary>
public List<AzureFunctionsKey> Keys { get; } = [];
Copy link
Member

Choose a reason for hiding this comment

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

Do we want this set of keys to be mutable or is it actually a fixed collection that we initialize once?

Copy link
Author

Choose a reason for hiding this comment

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

Customers can call resource.PublishWithFunctionKey("MyTrigger") (which I haven't added yet)... so the list needs to be built up as these PublishWith___Key() calls are made. If that can be done all at once at the end, sure... just wasn't sure what pattern to use?

Copy link
Member

Choose a reason for hiding this comment

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

If we were to take inspiration from the WithRoleAssignments API we would make WithFunctionKey take a list of (AzureFunctionsKeyType Type, string TriggerName). Then we can call WithAnnotation(new AzureFunctionsAnnotation) once in the call with the list of items.

}

return containerApp;
}

private static void ProcessFunctionsSecretVolumes(AzureFunctionsAnnotation annotation, AzureResourceInfrastructure infra, ContainerApp app)
Copy link
Member

Choose a reason for hiding this comment

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

Parts of this feel generic enough that we can probably plug them into a ProcessSecretVolumes method and take the functions specific volume name and properties?

Copy link
Author

Choose a reason for hiding this comment

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

yes I agree... but that didn't exist yet and I don't know all the ins-and-outs of volume setups and what may be needed. I only knew the exact parts I needed, and I barely knew that :-)

/// </summary>
/// <param name="builder"></param>
/// <returns></returns>
public static IResourceBuilder<AzureFunctionsProjectResource> PublishWithAdminKey(this IResourceBuilder<AzureFunctionsProjectResource> builder)
Copy link
Member

Choose a reason for hiding this comment

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

Do we anticipate that end-users will need to call this API in their code (or overloads of it that target different key types)?

Copy link
Author

@brettsam brettsam Jun 18, 2025

Choose a reason for hiding this comment

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

this API, not really, no -- I went ahead and made it internal now actually. And my latest commit has the public ones for other key types

The goals with these PublishWith__Key() APIs are:

  • By adding an Admin and a "default" Host key automatically, the app is ready-to-run for all scenarios
  • Customers can also call .PublishWithFunctionKey("MyFunction") to add a function-specific key
  • We will auto-gen the key for you in Aspire to make sure it's an HIS. And make sure it's named and mounted correctly for our secrets repository to read it.
  • If you want to edit a key, you do that via ACA secret management.
  • You can even manually create them via ACA secret management -- you just have to name them correctly and have them go to the right mounted volume (something we can document)

@davidfowl
Copy link
Member

Is there any reason this needs to be a volume and not an env variable?

@davidfowl
Copy link
Member

Can you write a test that generates the bicep so we can see it.

@brettsam
Copy link
Author

Is there any reason this needs to be a volume and not an env variable?

If I recall... the main reason was b/c Functions already has a KubernetesSecretsRepository that reads secrets from files, so all of the details were worked out/tested/etc. We do not have an Environment-based one.

@brettsam brettsam force-pushed the brettsam/func_keys branch from 81ab656 to e21fa8b Compare July 1, 2025 14:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-integrations Issues pertaining to Aspire Integrations packages community-contribution Indicates that the PR has been added by a community member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Aspire: Support secret creation on ACA
3 participants