1

In our solution we have multiple web api projects created and these are hosted on azure web app independently.Because of which each web api project has different url, like following

https://www.xyz.azurewebsite.net/api/employee/getemployee https://www.abc.azurewebsite.net/api/department/getdepartment

Here Employee is one web api project and department is second one.

So my question is how can we host these web api under same webapp/domain on azure.

enter image description here Because what has happened I have added blank api project with only web api method. I have made Set as startup project. and while pushing the code it has overridden other api project profile and after that the other api stopped working.

Thanks for the help !

7
  • under same webapp/domain on azure Could you elaborate more? Commented Aug 31, 2018 at 19:05
  • @Win whatever number of web api projects and there web api they should have same url. Right now its different like i have shown in the question Like xyz.azurewebsite.net/api/employee/getemployee xyz.azurewebsite.net/api/department/getdepartment. This xyz means my client/company name. Commented Aug 31, 2018 at 19:08
  • It all depends on how you create projects in Visual Studio and how you deploy them to Azure. Could you show the screen shot of VS solution? Commented Aug 31, 2018 at 19:11
  • 4
    Well, you have to two different projects. Without combing those two controllers into a single project, you cannot publish and access them via same endpoint like you described. If you are aiming for microservices, you might want to look at API Gateway (Azure API Management). Commented Aug 31, 2018 at 19:29
  • 1
    Azure API Management is nothing more than a facade/gateway. The correct platform for microservices is Service Fabric. Commented Aug 31, 2018 at 20:13

2 Answers 2

1

What if your application needs to display all employees for a given department? How will you solve that with your given setup? How will you be ensuring referential integrity across your department and employee stores? What you are designing is what I like to refer as nanoservices and are bound to have serious implications for your applications performance and scalability. HATEOUS in my experience falls apart when your domain is highly relational and there are no logical and evident boundaries. Considering what I can see in your code, you will be better off with 1 Web Api project with an Employee and Department controller. Consider microservices when you need to scale your services independent of each other or if there is a natural bounded context that can be inferred.

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

4 Comments

This was done purely considering micro services architecture. Though we haven't started on it. We also have CI/CD pipeline in place for APIs.
What if your application needs to display all employees for a given department? How will you solve that with your given setup? How will you be ensuring referential integrity across your department and employee stores? What you are designing is nanoservices and are bound to have serious implications for your applications performance and scalability. HATEOUS in my experience falls apart when your domain is highly relational and there are no logical and evident boundaries.
Ok That make send. So you are saying instead of multiple web api project, we should have one with multiple controllers. Because We were thining what will happen in case of authentication functionality ?
That is correct. I've updated my answer as well now that I understand what you're trying to accomplish. Please accept if it addresses your question.
0

You can host two or more projects on the same Azure Web App by setting up multiple Virtual Applications. To do so:

  1. Log into your Azure Portal and navigate to your Web App blade.
  2. Click on the Application Settings menu option on your Web App.
  3. Scroll to the bottom and define a new Application. "/" already points to your /wwwroot directory. You can define a virtual path of "/employee", set the physical path to "/employee", and set the Type to "Application".

When you publish your Employee web app, you'll need to make sure to append the virtual path to your Site name and Destination Url under the Publish -> Connection tab.

Note: since these are separate virtual applications, they will not share state.

2 Comments

Is this best practice ? I mean people are actually following this.
It really depends on what you're trying to accomplish. If both of your web applications are part of the same app and need to share state, then combining the controllers into one project is the cleaner approach. If you are trying to pack multiple web applications into a single Azure Web App in order to reduce hosting cost and increase density, then this is a good approach.

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.