Azure Worker role Webapi hosting + Service Bus - asp.net-web-api

I would like to be able to pump messages from the azure service bus and dispatch them to Webapi controllers in a worker role. I have seen this excellent (series) article http://pfelix.wordpress.com/2012/03/15/asp-net-web-api-creating-an-host-using-azure-service-bus/ which is very interesting but seems to use WCF . I would prefer to use the newer webapi framework instead. Has anyone already wrapped QueueClient as a source for a custom host?

The post that you refer does use the newer Web API framework. Internally, it uses the WCF relay bindings similarly to what happens with Web API self-hosting, which also uses WCF internally.
The code is available here: https://github.com/pmhsfelix/WebApi.Explorations.ServiceBusRelayHost
Hope this helps
Pedro

Related

Cloud Provider SLAs exposed via RESTful APIs

I was wondering if any of the major cloud providers (AWS, Azure, Google) exposed their SLAs for virtual machines via a RESTful API.
Basically, I am looking for the information available on these pages:
https://aws.amazon.com/compute/sla/
https://cloud.google.com/compute/sla
https://azure.microsoft.com/en-gb/support/legal/sla/virtual-machines/v1_8/
Does anyone know if this information is exposed by any of these providers via a RESTful API?
Many thanks.
I was informed by Azure Support that this service is not provided by them.
On Google Cloud Platform there is no way to check the information that you are asking via REST API.
Can you explain your use case and maybe we can find a workaround?
Best regards

Can you host Web API and ServiceStack on same root route?

I have a third party Reporting tool (telerik) that uses Web API services to provide reporting services. The path to the reporting services begins with api/, I can get either ServiceStack or Telerik to operate separately or together if they are on different paths, but is it possible to have them on the same path using IgnoreRoute so that the route is ignored by the Web API service and handled by ServiceStack? I would like to have something like api/reports for Telerik and api/rest for ServiceStack. I'm sure there is some technical reason why this is not possible but would like to know why.

WebAPI/OWIN hosting confusion

There are so many things today? I'm looking to host web api in windows service but recently I come across this link http://www.asp.net/web-api/overview/hosting-aspnet-web-api/use-owin-to-self-host-web-api
is this a new thing and should we use this OWIN, Please suggest?
Does this OWIN make thing more faster or what are the benefit to use OWIN?
OWIN makes things a bit simpler and cleaner when self-hosting.
You might want to check out the OWIN Web API 2 self host in windows service example on GitHub.
Web API is based on owin, and owin is an abstraction. Instead of those old times when web api team was responsible for making web api availble on several hosts such as IIS, self host, etc, it just relays on owin. Owin has several implementations based on IIS, ASP.NET, ASP.NET Core, Self Host etc.
For example see the following sample of running asp.net web api odata on asp.net core using owin & kestrel: https://github.com/ymoradi/OwinAspNetCore
After doing more searching OWIN and Kanata are just layers on top particularly WebAPI, they are rather an convenient composer from what I understand from here http://msdn.microsoft.com/en-us/magazine/dn451439.aspx
for my purpose, I use WebAPI ONLY, so I don't need all these extra things.

Sharing a SignalR hub between a WebApi and MVC project

Is there a recommended approach to sharing a SignalR hub across two applications?
The actual situation is a public facing WebAPI project and an internal MVC WebApp. What I'd like to do is call methods on a SignalR hub from the WebAPI project and have the results of these methods pushed to clients connected via the MVC app.
Would the best option be to create a third 'Hub' project and have both projects connect to that? If so, how are the hub instances managed? Can both applications get a reference to the same hub from distinct app pools (and possibly hosts)?
I read a little bit about GlobalHost.ConnectionManager.GetHubContext, would this suffice to get a effectively a singleton hub which both apps could use?
Any thoughts greatly appreciated.
Just setup signalr message routing through a SQL Server table. It will automatically connect all hubs using the same routing setup. Nothing else to do, it's magic.
GlobalHost.DependencyResolver.UseSqlServer(ConfigurationManager.ConnectionStrings["signalr"].ConnectionString);
You will need the following nuget package: Microsoft.AspNet.SignalR.SqlServer

What is the difference among Web Service, WCF and Window Service?

I got a lot of theoretical answers from Google that WCF is better than Web Service etc. etc. But I want to know from the programming and implementation point of view. I am very new to coding and want to know that how do we implement all three of these technologies? How are they different and in which scenario we should used which technologies?
Thank you in advance.
A web service is an API that is hosted for access via a network connection - often the internet - and usually accessed over HTTP (or HTTPS).
WCF is a Microsoft .NET development framework that can be used to implement web services. That is, WCF-services are a subset of all web-services.
Windows services are a separate beast entirely: they are long-running programs that run on your local Windows machine, typically with no user interaction and on system accounts. They are used to handle many things in Windows, from low-level driver functionality to software updates.
You're really comparing apples and oranges. A web service is simply a program that you can "call" using the HTTP protocol. Typically, HTTP requests sent to the service contain some XML describing the method called and any parameters. The response from the service likewise contains XML with the return value and any output parameters. It's a little more complicated than this, but it gives you the basic idea.
Windows Communication Foundation (WCF) is a framework for building network services. You can use this framework to build web services if you wish. I suspect that what's tripping you up are the various Visual Studio project templates. You have one for WCF services and one for web services. The web service template builds a web service that runs inside of IIS. The WCF template gives you far more flexibility (you can make a web service as a stand-alone application, for example), but it is far more complicated.
If you're just beginning, I'd start with web service template and IIS-based web services.
MSDN is always a good reference:
Web Service Tutorial:
http://msdn.microsoft.com/en-us/library/8wbhsy70%28VS.80%29.aspx
WCF Tutorial:
http://msdn.microsoft.com/en-us/library/ms734712.aspx
I think its always easier to learn by doing.
Good luck

Resources