WebAPI as Micro service in Cloud - c#

Can we host the normal Asp.Net MVC WebApi built with c# code and not in .net core in Azure or AWS micro service platform?

Depends on what you mean micro service. Microservices is mostly an architecture and not a specific platform. They are related to containers in a sense, but it's not the same thing.
Based on this: https://azure.microsoft.com/en-us/solutions/microservice-applications/, related technologies include:
Service Fabric
Get automatic scaling, rolling upgrades, and self-healing from faults with a custom-built microservices framework.
Azure Kubernetes Service (AKS)
Use a fully managed Kubernetes service to handle provisioning, upgrading, and scaling cluster resources on demand.
Azure Functions
Build apps with simple, serverless functions that scale on demand based on the number of executions—without managing infrastructure.
API Management
Expose and publish specific parts of your applications as an API no matter where the implementation is hosted.
Kubernetes and ServiceFabric support containers which can be hosted on windows with iis, so the answer is yes.
The api management is agnostic and is used to expose, secure e.t.c your APIs.
You can even host .net web api on app service: https://learn.microsoft.com/bs-latn-ba/dotnet/azure/dotnet-howto-migrate-app-service?view=azure-dotnet
In app service you can scale up and scale out.
Functions are serverless and they are not related to MVC api, they need new implementations.

Related

Host legacy WCF services in Azure

Does anyone know what the options are for hosting legacy .NET4+ WCF services in Azure?
I have heard that App Services are not to be used, but I have trouble finding any sources.
You can host your WCF services in multiple ways
on IIS
as Windows Service
as Console App
For the windows Service / Console App, you can:
Setup a VM and also install it
For the other options:
You can deploy on App Service or also on a VM with IIS installed.
More info:
https://aspdotnetcodehelp.wordpress.com/2017/11/13/hosting-wcf-in-azure-app-service/
The basic areas to consider when migrating an existing .NET application to Azure are:
https://learn.microsoft.com/en-us/dotnet/azure/migration/choose
Compute choices
Database choices
Networking and security considerations
Authentication and authorization considerations
To host a WCF service in Azure, you can check out the following tutorials.
Expose an on-premises WCF service to a web application in the cloud by using Azure Relay
Deploying an existing WCF service to Azure

OpenTelemetry for WCF services hosted in IIS and Windows Services

Currently, we have Thick Client (WPF application run in customer environment) and WCF services hosted in Cloud (as IIS/Windows services applications).
Thick Client runs from customer environment. It is always a pain to track issues related to Thick Client customer-facing issues. We are thinking to implement OpenTelemetry to tracking the end-to-end tracing/logs (WPF -> WCF) and also standardize the logging.
Is it a good idea to implement OpenTelemetry? I have seen a lot of samples related .net core but not WCF Services hosted in Windows Services. Please share any reference articles and best OpenTelemetry samples related to WPF -> WCF end-to-end tracing.

Web Api and web ui in same application/service

For my AngularJS web application I use Azure Service Fabric as my backend. For that I created a stateless web api service.
Do I have to put the frontend /client-side AngularJS code in the same application type or the same stateless service? Is it useful to create another stateless service for the web ui?
As others have mentioned, you can host your Angular web app anywhere you like; there are no restrictions imposed by Service Fabric in this regard.
That said, in your case a simple solution is to have your front-end web app and your web api in the same stateless service. Basically you treat this as a regular old ASP.NET MVC application, and ASP.NET MVC makes it fairly easy to have an API and web UI in the same MVC project. Here are a couple examples of this:
ASP.NET 5 MVC application with an API and a UI: https://github.com/Azure-Samples/service-fabric-dotnet-getting-started/tree/master/Services/Chatter
Single-page jQuery app with an API self-hosted with Katana: https://github.com/Azure-Samples/service-fabric-dotnet-management-party-cluster/tree/master/PartyCluster
As to the question of why do you need Service Fabric to host a front-end file. There are trade-offs here. Assuming the front-end is a web application that's meant to be part of a larger Service Fabric application - as it is in your case - it's nice to have everything in one place using one set of tools on the same SDK with the same deployment process hosted on the same cluster, rather than having a completely separate process, tools, SDK, and hosting environment for one part of your application. You also get all the Service Fabric goodness like rolling upgrades, health monitoring, high availability and auto failover, etc. The downside is that you don't get the super easy-to-use tools for web applications that come with, say, Azure App Service.

HTML5 with .NET backend App, compatible with both standalone Windows and Azure?

I need to design an HTML 5 responsive, and simple app that should work on both internal Win server and on Azure.Our Client wants to check out Azure but maybe later he will want this app to be on its own on premise servers. Our Developers are almost all .NET back ends, with basic knowledge in HTML 5, Javascript, Jquery, and bootstrap. We accepted the challenge because the project is tiny and interesting, the point is, is possible to have 1 project that can be deployed to azure or IIS with no problem? and what kind of project should we create? I think that a simple asp.net project with some web methods and js will do the job, but I don't know if it will work on azure too. Back n 2010 I did something that way but now I am not sure it's still valid
Important: the web application should be able to query oracle on premise server, via web service but not sure if take azure service bus or azure vpn
It depends on how you build your application. I have built applications in the past that works both on-premise and on Azure. As long as you don't access any Azure specific features, there's no problem to deploying the web application project to an on-premise IIS.
If you use Azure-specific features or services from Azure, such as Azure SQL DB, you have to built an on-premise version. In my case it was simple as changing the connection string and the rest was done by Entity Framework, but you can use an IoC container, such as Unity, to change your implementation based on the environment you're running on. If the Azure environment is available (check through RoleEnvironment.IsAvailable) you resolve the Azure-specific implementation of some features and if not the on-premise implementation. In most cases that are just a few dependencies, for example if you use a worker role on Azure and a Windows Service on-premise.

What is the preferred method for building web services in .Net?

I am confused as to what is the best method for building a web service in .net. Giving the fact that it needs to be highly scalable. Any suggestions?
If your consumers are all .NET, look at WCF:
http://msdn.microsoft.com/en-us/library/ms731082.aspx
Otherwise, plain old SOAP services are good. Both are scalable.
IIS is designed for scalability, so I'd definitely consider using ASP.NET web services rather than hosting my web service within a windows service using WCF.
Of course, you can host your WCF web service within IIS. Here's an article on how to do this.
This article is a little old, but it details the benefits of hosting your web service in IIS within the Recommendations section:
Scalability—It is very easy to scale out a Web service using load-balancing technology such as Windows Network Load Balancing, or hardware devices from vendors such as Cisco and F5. More on this subject to follow.
Availability—ASMX Web services can be configured to be highly available using a combination of technologies such as load-balancing combined with the powerful capabilities of the IIS6 infrastructure built into Windows 2003 Server (such as automatic recycling and restarting of failed services).
I guess the point is no matter if you want to use ASP.NET web services or WCF, definitely host it in IIS.
We use WCF. You can also use Spring.Services very powerfull framework.
What stragedy you whant to use service-first or contract-first?
As per as i know it totally depend on the what kind of web services u want to develop....
if u want to secure,state management and other facilities that can be required for web services ....i prefer WCF (Window communication foundation).
The global acceptance of Web services, which includes standard protocols for application-to-application communication, has changed software development. For example, the functions that Web services now provide include security, distributed transaction coordination, and reliable communication. The benefits of the changes in Web services should be reflected in the tools and technologies that developers use. Windows Communication Foundation (WCF) is designed to offer a manageable approach to distributed computing, broad interoperability, and direct support for service orientation.
for more information about and Problem Example
Use WCF.
It allows you to expose a service using multiple protocols and multiple security contexts.
A very good resource for learning WCF is Michele Bustamante's book Learning WCF.
http://www.amazon.com/Learning-Hands-Michele-LeRoux-Bustamante/dp/0596101627
Note: If you do get this book, she has an updated version of Chapter 1 and an appendix on her website.
Her website is also a good source of up-to-date information: http://www.dasblonde.net/default.aspx

Categories

Resources