Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Point root domain to Azure Function

In our project requirements we need to deal with a number of redirects where requests come in the form of example.com/some-uri and based on this some-uri get redirected to various places.

As all of our existing apps are already hosted in Azure (hundreds of services, databases, applications, etc, etc.), Azure Functions seem a very reasonable choice. The workload is extremely simple: match the incoming uri against a table and issue a 301 redirect to the corresponding target.

Unfortunately, with Azure Function there is no public IP address and I cannot use CNAME on the root domain (that is, I cannot use DNS syntax @ CNAME somefunction.something.azure.net)

I don't want to have to pay for an app service to just deal with these redirects. The number of requests I expect is well within the free allocation of function invocations, therefore I would be getting this essentially for free.

How can I point the root of my example.com domain to the function?

like image 458
Aleks G Avatar asked Nov 01 '18 11:11

Aleks G


People also ask

How do I point my domain to Azure?

Sign in to the Azure portal using a Global administrator account for the directory. Search for and select Azure Active Directory from any page. Then select Custom domain names > Add custom domain. In Custom domain name, enter your organization's new name, in this example, contoso.com.

Can you add a custom domain for the Azure function?

You can configure a vanity or custom domain for Azure Function Apps, Public IP addresses, App Service (Web Apps), Blob storage, and Azure CDN.

How do I point my GoDaddy domain to Azure?

Go to GoDaddy portal - >Domains->Manage DNS -> Edit/Add the A Record and map the Azure web app IP as shown in the below figure. Now go to Azure portal -> custom domain of the web app service, click on Add custom Domain icon and enable the A record mapping as shown in below figure.

How do I add Cname records to Azure?

In the left pane of the app page in the Azure portal, select Custom domains. Select Add custom domain. Type the fully qualified domain name that you added a CNAME record for, such as www.contoso.com . Select Validate.


Video Answer


3 Answers

To finish this question, the answer is, it's not possible. Naked domain record cannot be CNAME and there is no ip address for a function to create A record.

EDIT: Turns out, it is possible, but not directly. When creating Azure Functions app, you can select "Consumption plan" or "App Service plan". With App Service plan, on tiers B1 and above you do get a static IP address associated with it. Moreover, you can even use reserved IP addresses.

like image 119
Aleks G Avatar answered Oct 22 '22 11:10

Aleks G


As far as I know there is currently now way to bind your "domain root" (example.com) to an Azure Function App.

I solved that problem for me by decoupling that with a (pre-)service that manages the domain and ssl topics for me (like Cloudflare)

If you you want to stay on Azure maybe the Azure API Management is an option for you.

like image 23
Sebastian Achatz Avatar answered Oct 22 '22 10:10

Sebastian Achatz


For anyone else stumbling upon this thread, Azure Function Apps nowadays support root domains using A records even in Consumption tier. More information in the documentation: https://learn.microsoft.com/en-gb/azure/app-service/app-service-web-tutorial-custom-domain.

Edit: Turns out... it doesn't. I must have been confused by the IP Address field's tooltip in the Custom Domains tab of Function Apps, where it says "Use this IP address to configure your DNS settings for A records". Then when you click "Add custom domain" and try to add an A record it says "A records are not supported for Consumption based Function Apps."

I have used Azure Static Web Apps to host some of my websites and there is a Function App in the background as your app's API. Static Web Apps support A records so that is a way to have your Functions behind a root domain. However, Static Web Apps in free tier have limitations and the non-free tier is not pay-for-what-you-use like Consumption plan is.

like image 34
mikkark Avatar answered Oct 22 '22 11:10

mikkark