Azure / azure-functions-python-worker

Python worker for Azure Functions.
http://aka.ms/azurefunctions
MIT License
346 stars 107 forks source link

Supporting Federated Credentials in Azure Functions #1644

Open anshuman-goel opened 2 months ago

anshuman-goel commented 2 months ago

Binding Type

Both

Expected Behavior

Currently Azure Function trigger like Event Hub, Queue trigger, etc, support Connection strings, Managed Identity. However, it does not support Federated Credentials which inhibits writing an azure function in a different tenant from where the trigger is deployed.

For example, I cannot have an Event Hub triggered Azure Function in tenant A where Event Hub resides in tenant B.

JAdluri commented 1 month ago

Hello @anshuman-goel could you please mention steps to repro.

anshuman-goel commented 1 month ago

@JAdluri Please find the steps:

To reproduce the issue where Azure Function triggers do not support Federated Credentials, inhibiting the ability to write an Azure Function in a different tenant from where the trigger is deployed, follow these steps:

Steps to Reproduce

  1. Set Up Azure Environment:

    • Ensure you have access to two Azure tenants: Tenant A and Tenant B.
    • In Tenant B, create an Event Hub namespace and an Event Hub.
  2. Create an Azure Function in Tenant A:

    • In Tenant A, create a new Azure Function App.
    • Choose a Python runtime stack and create the function app.
  3. Configure Event Hub Trigger:

    • In the Azure Function App in Tenant A, add a new function with an Event Hub trigger.
    • Attempt to configure the Event Hub trigger to connect to the Event Hub in Tenant B.
  4. Connection String Configuration:

    • Use the connection string from the Event Hub in Tenant B to configure the Event Hub trigger in the Azure Function in Tenant A.
    • Verify that the connection string works and the function can be triggered by events in the Event Hub.
  5. Attempt to Use Federated Credentials by using Managed Identity and Service Principal:

    • Create a Managed Identity and add to Function App.
    • Setup the Federated Credentials by creating new App Registration and the above created Managed Identity between cross tenants. Detailed steps on it are being omitted for brevity.
    • Try to configure Federated Credentials for the Azure Function in Tenant A.
    • Attempt to use Federated Credentials to access the Event Hub in Tenant B.
    • Observe that there is no support for Federated Credentials in the Azure Function trigger configuration.

Expected Outcome

Actual Outcome

Conclusion

The issue is that Azure Function triggers like Event Hub, Queue trigger, etc., do not support Federated Credentials, which prevents cross-tenant configurations using Federated Credentials.

JAdluri commented 1 month ago

@anshuman-goel Thank you for detailed steps. Will let you know furtherly