ServiceBus application run in the cloud crashesHi.<br/><br/>I'm attempting to use the Service Bus to create a simple service to import data into a Azure Table. The application is to be run in Azure (that is, the application is to be uploaded to the cloud, one or more clients are to be run outside of the cloud). It consists mainly of a worker role and a web role (though, only the worker role is of interest here, the web role should only view the result). The worker role sets up an endpoint, authenticates with the solution name and password and everything. The client will then connect to this service's endpoint, and sends data to it by calling the &quot;Import&quot; function on the service contract.<br/><br/>The service runs perfectly when I run the cloud service in the development fabric. It even registers in the ATOM feed in the Service Bus &quot;control panel&quot; on MS's management site, and I can connect using my client.<br/><br/>The problem comes when I deploy the service application in the cloud. Then the worker (sometimes) runs for a few minutes, then its status is set to &quot;Stopped&quot;. While it's running, no service is registered in the ATOM feed. Then sometimes it starts up again, runs for a little while, then stops again. My guess is that an exception of some sort is thrown, and the application crashes. I've attempted to look at the logs, but for some reason, no logs are generated for my worker role, only my web role. So it's quite hard to debug. I'll post the code for my worker's Start() function below:<br/> <div style="color:black;background-color:white"> <pre> ServiceHost host; <span style="color:blue">public</span> <span style="color:blue">override</span> <span style="color:blue">void</span> Start() { RoleManager.WriteToLog(<span style="color:#a31515">&quot;Information&quot;</span>, <span style="color:#a31515">&quot;Worker started!&quot;</span>);<br/> <br/><br/><br/> <span style="color:green">//Create the service</span> Uri uri = ServiceBusEnvironment.CreateServiceUri(<span style="color:#a31515">&quot;sb&quot;,</span> <span style="color:#a31515">&quot;(my solution's name)&quot;</span>, <span style="color:#a31515">&quot;importservice&quot;</span>); host = <span style="color:blue">new</span> ServiceHost(<span style="color:blue">typeof</span>(ImportService), uri); ContractDescription contract = ContractDescription.GetContract(<span style="color:blue">typeof</span>(IImportService), <span style="color:blue">typeof</span>(ImportService)); ServiceEndpoint serviceEndpoint = <span style="color:blue">new</span> ServiceEndpoint(contract);<br/> serviceEndpoint.Address = <span style="color:blue">new</span> EndpointAddress(uri); serviceEndpoint.Binding = <span style="color:blue">new</span> NetTcpRelayBinding(); <span style="color:green">//Set up authorization</span> TransportClientEndpointBehavior creds = <span style="color:blue">new</span> TransportClientEndpointBehavior(); creds.CredentialType = TransportClientCredentialType.UserNamePassword; creds.Credentials.UserName.UserName = <span style="color:#a31515">&quot;(my solution name)&quot;</span>; creds.Credentials.UserName.Password = <span style="color:#a31515">&quot;(my solution's password)&quot;</span>; serviceEndpoint.Behaviors.Add(creds); <span style="color:green">//Make it public</span> ServiceRegistrySettings settings = <span style="color:blue">new</span> ServiceRegistrySettings(); settings.DiscoveryMode = DiscoveryType.Public; serviceEndpoint.Behaviors.Add(settings); <span style="color:green">//Set up the listener</span> host.Description.Endpoints.Add(serviceEndpoint); host.Open();<br/> <br/> <span style="color:blue">while </span>(<span style="color:blue">true)</span> { RoleManager.WriteToLog(<span style="color:#a31515">&quot;Information&quot;,</span> <span style="color:#a31515">&quot;Working...&quot;</span>); Thread.Sleep(10000); } } </pre> </div> <br/>Here is my service contract interface and my actual service:<br/> <div style="color:black;background-color:white"> <pre> [ServiceContract(Name=<span style="color:#a31515">&quot;ImportService&quot;</span>)]<br/>  <span style="color:blue">public</span> <span style="color:blue">interface</span> IImportService<br/>  {<br/>  [OperationContract]<br/>  <span style="color:blue">void</span> ImportXML(<span style="color:blue">string</span> xmlDoc);<br/>  }<br/> [ServiceBehavior]<br/>  <span style="color:blue">public</span> <span style="color:blue">class</span> ImportService : IImportService<br/>  {<br/>  <span style="color:blue">public</span> <span style="color:blue">void</span> ImportXML(<span style="color:blue">string</span> xmlDoc)  {<br/>  DataLayer dal = <span style="color:blue">new</span> TablesDataLayer();<br/>  dal.Import(xmlDoc);<br/> RoleManager.WriteToLog(<span style="color:#a31515">&quot;Information&quot;,</span> <span style="color:#a31515">&quot;Importing XML document...&quot;</span>);<br/>  }<br/>  } </pre> </div> <br/>The code in the ImportXML function never gets called, since it crashes before I'm able to call it. So I'm quite sure the problem is somewhere else. Does anyone have any idea of what I can have done wrong here? Or maybe how to get the worker role's logging up and running properly so I can debug this?<br/><br/>Best regards,<br/>Hallgeir© 2009 Microsoft Corporation. All rights reserved.Thu, 02 Jul 2009 06:38:47 Z88621667-917a-44ad-89f9-1f5b839206eehttp://social.msdn.microsoft.com/Forums/en-US/netservices/thread/88621667-917a-44ad-89f9-1f5b839206ee#88621667-917a-44ad-89f9-1f5b839206eehttp://social.msdn.microsoft.com/Forums/en-US/netservices/thread/88621667-917a-44ad-89f9-1f5b839206ee#88621667-917a-44ad-89f9-1f5b839206eeHallgeir Lienhttp://social.msdn.microsoft.com/Profile/en-US/?user=Hallgeir%20LienServiceBus application run in the cloud crashesHi.<br/><br/>I'm attempting to use the Service Bus to create a simple service to import data into a Azure Table. The application is to be run in Azure (that is, the application is to be uploaded to the cloud, one or more clients are to be run outside of the cloud). It consists mainly of a worker role and a web role (though, only the worker role is of interest here, the web role should only view the result). The worker role sets up an endpoint, authenticates with the solution name and password and everything. The client will then connect to this service's endpoint, and sends data to it by calling the &quot;Import&quot; function on the service contract.<br/><br/>The service runs perfectly when I run the cloud service in the development fabric. It even registers in the ATOM feed in the Service Bus &quot;control panel&quot; on MS's management site, and I can connect using my client.<br/><br/>The problem comes when I deploy the service application in the cloud. Then the worker (sometimes) runs for a few minutes, then its status is set to &quot;Stopped&quot;. While it's running, no service is registered in the ATOM feed. Then sometimes it starts up again, runs for a little while, then stops again. My guess is that an exception of some sort is thrown, and the application crashes. I've attempted to look at the logs, but for some reason, no logs are generated for my worker role, only my web role. So it's quite hard to debug. I'll post the code for my worker's Start() function below:<br/> <div style="color:black;background-color:white"> <pre> ServiceHost host; <span style="color:blue">public</span> <span style="color:blue">override</span> <span style="color:blue">void</span> Start() { RoleManager.WriteToLog(<span style="color:#a31515">&quot;Information&quot;</span>, <span style="color:#a31515">&quot;Worker started!&quot;</span>);<br/> <br/><br/><br/> <span style="color:green">//Create the service</span> Uri uri = ServiceBusEnvironment.CreateServiceUri(<span style="color:#a31515">&quot;sb&quot;,</span> <span style="color:#a31515">&quot;(my solution's name)&quot;</span>, <span style="color:#a31515">&quot;importservice&quot;</span>); host = <span style="color:blue">new</span> ServiceHost(<span style="color:blue">typeof</span>(ImportService), uri); ContractDescription contract = ContractDescription.GetContract(<span style="color:blue">typeof</span>(IImportService), <span style="color:blue">typeof</span>(ImportService)); ServiceEndpoint serviceEndpoint = <span style="color:blue">new</span> ServiceEndpoint(contract);<br/> serviceEndpoint.Address = <span style="color:blue">new</span> EndpointAddress(uri); serviceEndpoint.Binding = <span style="color:blue">new</span> NetTcpRelayBinding(); <span style="color:green">//Set up authorization</span> TransportClientEndpointBehavior creds = <span style="color:blue">new</span> TransportClientEndpointBehavior(); creds.CredentialType = TransportClientCredentialType.UserNamePassword; creds.Credentials.UserName.UserName = <span style="color:#a31515">&quot;(my solution name)&quot;</span>; creds.Credentials.UserName.Password = <span style="color:#a31515">&quot;(my solution's password)&quot;</span>; serviceEndpoint.Behaviors.Add(creds); <span style="color:green">//Make it public</span> ServiceRegistrySettings settings = <span style="color:blue">new</span> ServiceRegistrySettings(); settings.DiscoveryMode = DiscoveryType.Public; serviceEndpoint.Behaviors.Add(settings); <span style="color:green">//Set up the listener</span> host.Description.Endpoints.Add(serviceEndpoint); host.Open();<br/> <br/> <span style="color:blue">while </span>(<span style="color:blue">true)</span> { RoleManager.WriteToLog(<span style="color:#a31515">&quot;Information&quot;,</span> <span style="color:#a31515">&quot;Working...&quot;</span>); Thread.Sleep(10000); } } </pre> </div> <br/>Here is my service contract interface and my actual service:<br/> <div style="color:black;background-color:white"> <pre> [ServiceContract(Name=<span style="color:#a31515">&quot;ImportService&quot;</span>)]<br/>  <span style="color:blue">public</span> <span style="color:blue">interface</span> IImportService<br/>  {<br/>  [OperationContract]<br/>  <span style="color:blue">void</span> ImportXML(<span style="color:blue">string</span> xmlDoc);<br/>  }<br/> [ServiceBehavior]<br/>  <span style="color:blue">public</span> <span style="color:blue">class</span> ImportService : IImportService<br/>  {<br/>  <span style="color:blue">public</span> <span style="color:blue">void</span> ImportXML(<span style="color:blue">string</span> xmlDoc)  {<br/>  DataLayer dal = <span style="color:blue">new</span> TablesDataLayer();<br/>  dal.Import(xmlDoc);<br/> RoleManager.WriteToLog(<span style="color:#a31515">&quot;Information&quot;,</span> <span style="color:#a31515">&quot;Importing XML document...&quot;</span>);<br/>  }<br/>  } </pre> </div> <br/>The code in the ImportXML function never gets called, since it crashes before I'm able to call it. So I'm quite sure the problem is somewhere else. Does anyone have any idea of what I can have done wrong here? Or maybe how to get the worker role's logging up and running properly so I can debug this?<br/><br/>Best regards,<br/>HallgeirMon, 29 Jun 2009 07:01:33 Z2009-06-29T07:26:00Zhttp://social.msdn.microsoft.com/Forums/en-US/netservices/thread/88621667-917a-44ad-89f9-1f5b839206ee#d1aaa317-ff72-4492-952b-89c046de3d92http://social.msdn.microsoft.com/Forums/en-US/netservices/thread/88621667-917a-44ad-89f9-1f5b839206ee#d1aaa317-ff72-4492-952b-89c046de3d92BrentDaCodeMonkeyhttp://social.msdn.microsoft.com/Profile/en-US/?user=BrentDaCodeMonkeyServiceBus application run in the cloud crashesI believe I saw that the service bus assembly must be part of your deployment package. However, I can't confirm this yet (its on my plate for this week).Mon, 29 Jun 2009 12:54:36 Z2009-06-29T12:54:36Zhttp://social.msdn.microsoft.com/Forums/en-US/netservices/thread/88621667-917a-44ad-89f9-1f5b839206ee#d722cc33-cd1a-4dd1-b35c-1c8f3228d6cfhttp://social.msdn.microsoft.com/Forums/en-US/netservices/thread/88621667-917a-44ad-89f9-1f5b839206ee#d722cc33-cd1a-4dd1-b35c-1c8f3228d6cfHallgeir Lienhttp://social.msdn.microsoft.com/Profile/en-US/?user=Hallgeir%20LienServiceBus application run in the cloud crashesCheers. I'll check it out. :)Wed, 01 Jul 2009 07:05:47 Z2009-07-01T07:05:47Zhttp://social.msdn.microsoft.com/Forums/en-US/netservices/thread/88621667-917a-44ad-89f9-1f5b839206ee#91c39597-65ed-4675-b403-f1bde6dc7b44http://social.msdn.microsoft.com/Forums/en-US/netservices/thread/88621667-917a-44ad-89f9-1f5b839206ee#91c39597-65ed-4675-b403-f1bde6dc7b44Hallgeir Lienhttp://social.msdn.microsoft.com/Profile/en-US/?user=Hallgeir%20LienServiceBus application run in the cloud crashesThat worked perfectly! Thank you very much!Thu, 02 Jul 2009 06:38:33 Z2009-07-02T06:38:33Z