Hello Maxim,
Welcome to the Microsoft Q&A and thank you for posting your questions here.
I understand that you are facing issues while attempting to integrate their custom domain (www.mycustomdomainname.eu) with Azure Functions, particularly when authentication (Easy Auth) is enabled within the Function App. While the Function App operates successfully without the custom domain and authentication enabled, encountering errors occurs when attempting to access the Function App through the custom domain with authentication enabled.
To resolve this issue without wasting any time, you will need to focus your troubleshooting on Custom domain configuration and authentication.
I would have love to ask for detail error logs to been examined to identify the root cause of the internal server error, and any specific error codes or messages that provide insights into what might be causing the issue.
However, try the followings to address the issues faced by the user with integrating a custom domain with Azure Functions while maintaining authentication (Easy Auth).
- Double-check the CName and TXT records registered with the domain provider to ensure they accurately point to the Azure Function App. DNS changes might take some time to propagate. Ensure that the changes made to the DNS records have propagated across the internet. Also, in the Azure portal, navigate to the Function App settings and ensure that the custom domain is correctly configured under the "Custom domains" section.
- When enabling authentication (Easy Auth) for the Function App, ensure that the custom domain is listed as a valid redirect URI in the authentication settings. This is crucial for redirecting users back to the correct domain after authentication.
- Also, in the Azure portal, navigate to your Function App.
- Go to the "Authentication / Authorization" section under the "Settings" menu. Ensure that "App Service Authentication" is enabled.
- Under "Authentication Providers," select "Azure Active Directory."
- Add your custom domain (e.g., www.mycustomdomainname.eu) as a valid redirect URI.
- If the Function App exposes APIs accessed from a web application hosted on a different domain, ensure that CORS policies are properly configured. Update CORS settings to include the custom domain as an allowed origin.
- Check the authentication settings to ensure they align with the requirements for custom domain integration. Review any additional settings related to authentication, such as token lifetimes and identity providers, to ensure they are configured correctly. This is an example of how to configure authentication using Azure CLI:
Replace# Enable App Service Authentication for your Function App az webapp auth update --name <function-app-name> --resource-group <resource-group-name> --enabled true # Configure Azure Active Directory authentication provider az webapp auth update --name <function-app-name> --resource-group <resource-group-name> \ --aad-allowed-token-audiences https://<function-app-name>.azurewebsites.net/.auth/login/aad/callback \ --aad-client-id <client-id> \ --aad-client-secret <client-secret> \ --aad-token-issuer-url https://sts.windows.net/<tenant-id>/ \ --aad-token-issuer-url-templates https://<function-app-name>.azurewebsites.net/.auth/login/aad/callback # Add custom domain as a valid redirect URI az webapp auth update --name <function-app-name> --resource-group <resource-group-name> \ --aad-allowed-token-audiences https://<custom-domain>/.auth/login/aad/callback
<function-app-name>, <resource-group-name>, <client-id>, <client-secret>, <tenant-id>
, and<custom-domain>
with your actual values.
I hope this is helpful! Do not hesitate to let me know if you have any other questions. If the error persists, ensure you post detail error logs for more insight.
Please remember to "Accept Answer" if answer helped, so that others in the community facing similar issues can easily find the solution.
Best Regards,
Sina Salam