0

I'm building a website/API. I have two ASP.Net Core 3.1 projects:

  • MyProject.Site
  • MyProject.Api

They are both hosted in Azure as App Services:

  • myproject.api.azurewebsites.net
  • myproject.site.azurewebsites.net

Finally myproject.site.azurewebsites.net is mapped to my custom domain, https://myproject.com.

What I'd like to do is set up https://api.myproject.com to resolve to myproject.api.azurewebsites.net, but I can't see how to associate the two now that I have the primary domain linked to the site.

I have an A record for api with my domain registrar, but I noticed within Azure that both app services have the same IP address listed under the Custom Domains pane. (I would expect them to have different IPs since they're different sites.)

When I go to set up a subdomain on the domain registrar, it's asking for a directory, which I assume would be something like /api to indicate https://api.myproject.com would reroute to https://myproject.com/api. But that wouldn't that mean that I'd need to expose my API project through the /api route on my site project?

I'm new to domains and basic infrastructur-y stuff, so explanations of solutions are appreciated.

(I also had originally considered putting the API and the site in the same project. Then I probably wouldn't have this problem. But I soon found that I needed different authentication methods between them, so I split them to accommodate this requirement.)

4
  • 2
    You should be able to create a CNAME record for api that points to myproject.api.azurewebsites.net - This would be done in your domain management and you don't need to worry about a folder, this sounds like the domain registrar also does hosting. Commented Jul 2, 2020 at 9:30
  • 2
    Just in case you haven't already seen this: learn.microsoft.com/en-gb/azure/app-service/… Commented Jul 2, 2020 at 9:39
  • Do I need to remove the A record, or just add the CNAME? Commented Jul 3, 2020 at 4:18
  • 1
    Yes, if you have A for api, you need to remove it first then add the CNAME for api. Commented Jul 3, 2020 at 6:18

1 Answer 1

2

As @SmithMart 's comment, you just need to create a CNAME record for the api subdomain that points to another App Service myproject.api.azurewebsites.net in your domain management.

You don't worry about the directory, DNS will help resolve the name api.myproject.com to your real site myproject.api.azurewebsites.net.

You could follow the Tutorial: Map an existing custom DNS name to Azure App Service. You will get

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.