I am trying to host an external WCF service on Azure inside a production role.
I have a solution that works very nicely locally, but when I try to publish it to Azure, it goes into the initialization / busy / stop cycle.
The information I found on the Internet says different things:
http://www.theworkflowelement.com/2011/01/worker-role-service-hosting-faq.html (not possible)
http://code.msdn.microsoft.com/WCF-Azure-Worker-Role-on-b394df49 (possibly with hacking)
Other sources say this is possible, but I do not have a representative to publish more than two links.
The latter, when I try to publish it, freezes.
Does anyone know how to do this, or if it is really impossible? It would be very convenient to place it in the role of a worker, so I do not need to use svc and web.config mess, which entail a web role.
This is the code I'm using:
[ServiceContract(Namespace = "")] public interface IMyService { [OperationContract] [WebGet] string Echo(string s); } public class MyService : IMyService { public string Echo(string s) { return "hey " + s; } } public class TestPasswordValidator : UserNamePasswordValidator { public override void Validate(string userName, string password) { } } private static void StartService() { var endpoint = RoleEnvironment.CurrentRoleInstance.InstanceEndpoints["HttpsEndpoint"]; var uri = new Uri(endpoint.Protocol + "://" + endpoint.IPEndpoint + "/myservice"); var host = new ServiceHost(typeof(MyService), uri); host.Credentials.UserNameAuthentication.UserNamePasswordValidationMode = UserNamePasswordValidationMode.Custom; host.Credentials.UserNameAuthentication.CustomUserNamePasswordValidator = new TestPasswordValidator(); var mexBehavior = new ServiceMetadataBehavior(); mexBehavior.HttpsGetEnabled = true; mexBehavior.MetadataExporter.PolicyVersion = PolicyVersion.Policy15; host.Description.Behaviors.Add(mexBehavior); var soapBinding = new WSHttpBinding(SecurityMode.TransportWithMessageCredential); soapBinding.Security.Message.ClientCredentialType = MessageCredentialType.UserName; host.AddServiceEndpoint(ServiceMetadataBehavior.MexContractName, MetadataExchangeBindings.CreateMexHttpsBinding(), "mex"); host.AddServiceEndpoint(typeof(IMyService), soapBinding, "Soap"); var restBinding = new WebHttpBinding(WebHttpSecurityMode.Transport); restBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic; var restEndpoint = host.AddServiceEndpoint(typeof(IMyService), restBinding, ""); restEndpoint.Behaviors.Add(new WebHttpBehavior { HelpEnabled = true, DefaultOutgoingResponseFormat = WebMessageFormat.Json, AutomaticFormatSelectionEnabled = true, DefaultBodyStyle = WebMessageBodyStyle.WrappedRequest }); host.Open(); } public override void Run() { StartService(); while (true) { Thread.Sleep(10000); } } public override bool OnStart() {