can an App Service contain both an Api service and a web server?

Scott Cahill 0 Reputation points
2024-04-28T03:18:18.1633333+00:00

I want to run an App service that contains both a C# api and a Blazor web service to run against a CosmosDB database.

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
6,958 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Marcin Policht 12,165 Reputation points MVP
    2024-04-28T03:38:46.3666667+00:00

    As far as I can tell, this should work:

    1. Create an Azure App Service Plan: Start by creating an Azure App Service plan. This plan defines the compute resources (CPU, memory, etc.) and features available to your web applications. You can use the same App Service plan for hosting both your C# API and Blazor web application to optimize costs.
    2. Create an Azure App Service: Within the Azure portal, create a new Azure App Service for hosting your applications. You can choose the same App Service plan created in the previous step.
    3. Deploy your C# API: Deploy your C# API to the Azure App Service. You can deploy it as an ASP.NET Core application, which can include Web APIs built using ASP.NET Core MVC or ASP.NET Core Web API.
    4. Deploy your Blazor Web Application: Deploy your Blazor web application to the same Azure App Service alongside your C# API. Blazor applications can be deployed as part of an ASP.NET Core application and run within the same runtime environment.
    5. Configure Routing: Configure routing within your application to ensure that requests to the appropriate endpoints are handled correctly. For example, you may route requests to /api/* to your C# API and requests to other paths to your Blazor web application.

    If the above response helps answer your question, remember to "Accept Answer" so that others in the community facing similar issues can easily find the solution. Your contribution is highly appreciated.

    hth

    Marcin

    0 comments No comments