Skip to content

Conversation

@davidfowl
Copy link
Member

Description

This pull request introduces changes to enhance Azure Functions integration by adding support for the clientId environment variable. The updates ensure that the clientId is correctly injected into the environment variables for Azure Functions projects when applicable.

Fixes #8116

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?
    • Yes
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No
  • Does the change require an update in our Aspire docs?

// Always inject the connection string associated with the top-level resource
// for the Azure Functions host.
target[$"{connectionName}__accountEndpoint"] = ConnectionStringExpression;
target[$"{connectionName}__clientId"] = default!;
Copy link
Member Author

@davidfowl davidfowl Apr 18, 2025

Choose a reason for hiding this comment

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

This is a little hacky. Unclear if this signal is needed. We might be able to do something else like always set it in WithReference if it is harmless (we already always set AZURE_CLIENT_ID today anyways?)

cc @fabiocav @mattchenderson

Copy link
Contributor

Choose a reason for hiding this comment

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

It should generally be harmless to just set it in WithReference() today, but it's probably worth building some defensiveness in here. I actually realize we forgot to prescribe something for this scenario: I believe we still need {connectionName}__credential: managedidentity, as that's the signal used to engage this when AZURE_CLIENT_ID is missing. I don't know if the KEDA logic cares there, but that is how Microsoft.Extensions.Azure expects things.

I'm imagining a situation in which someone themselves specifies {connectionName}__credential, set to something that gets added in the future. AZURE_CLIENT_ID likely would be mapped the same, but I don't know that it's guaranteed (and I'm thinking of cross-tenant with MI+FIC, specifically). I think the safest approach would be to check the credential type. If it's not unspecified or "managedidentity", we wouldn't want to assume {connectionName}__clientId has these semantics, or that it should be set at all. If the user goes custom here, they become responsible for the full suite of config for that custom approach.

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't know if the KEDA logic cares there, but that is how Microsoft.Extensions.Azure expects things.

Are you pretty sure the KEDA doesn't support AZURE_CLIENT_ID?

Copy link
Contributor

@mattchenderson mattchenderson Apr 21, 2025

Choose a reason for hiding this comment

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

That was the case when we opened the issue, at least. I've not been made aware of any updates on that front if they did happen.

Copy link
Member Author

Choose a reason for hiding this comment

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

We should fix keda and make it respect AZURE_CLIENT_ID

@davidfowl davidfowl closed this May 7, 2025
@github-actions github-actions bot locked and limited conversation to collaborators Jun 6, 2025
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.

Implementors of IResourceWithAzureFunctionsConfig should set additional params for identity-based configuration.

2 participants