Advertisement
Guest User

Untitled

a guest
Sep 16th, 2014
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.91 KB | None | 0 0
  1. // Endpoint is defined as in ServiceDefinition.csdef as
  2. // HTTP, external port 8080, internal port 8080 (or 8081 - error both ways)
  3. RoleInstanceEndpoint externalEndPoint =
  4. RoleEnvironment.CurrentRoleInstance.InstanceEndpoints["Endpoint"];
  5. string baseAddress= String.Format("http://{0}", externalEndPoint.IPEndpoint);
  6. var maxsize = 1024 * 1024;
  7. var config = new HttpSelfHostConfiguration(baseAddress)
  8. {
  9. MaxBufferSize = maxsize, MaxReceivedMessageSize = maxsize
  10. };
  11. config.Routes.MapHttpRoute(
  12. name: "DefaultApi",
  13. routeTemplate: "api/{controller}/{id}",
  14. defaults: new { id = RouteParameter.Optional }
  15. );
  16.  
  17. // Create and open the server
  18. var server = new HttpSelfHostServer(config);
  19. server.OpenAsync().Wait();
  20.  
  21. // keep the worker thread alive
  22. while (true)
  23. Thread.Sleep(Timeout);
  24.  
  25. [0] One or more errors occurred.
  26. [1] HTTP could not register URL http://+:8081/. Your process does not have access rights to this namespace (see http://go.microsoft.com/fwlink/?LinkId=70353 for details).
  27. [2] Access is denied
  28.  
  29. <Endpoints>
  30. <InputEndpoint name="Endpoint" protocol="http" port="8080" localPort="8081" />
  31. </Endpoints>
  32.  
  33. host.AddServiceEndpoint(
  34. typeof(IEchoService), new BasicHttpBinding(BasicHttpSecurityMode.None) { HostNameComparisonMode = HostNameComparisonMode.Exact }, "echo");
  35.  
  36. <WorkerRole name="WorkerRole" vmsize="ExtraSmall">
  37. <Runtime executionContext="elevated">
  38. </Runtime>
  39. </WorkerRole>
  40.  
  41. <Startup>
  42. <Task executionContext="elevated" commandLine="startupInstall.cmd">
  43. <Environment>
  44. <Variable name="ENDPOINTPORT ">
  45. <RoleInstanceValue xpath="/RoleEnvironment/CurrentInstance/Endpoints/Endpoint[@name='Endpoint']/@port" />
  46. </Variable>
  47. </Environment>
  48. </Task>
  49. </Startup>
  50. <Endpoints>
  51. <InputEndpoint name="Endpoint" protocol="http" port="8080" localPort="8080" />
  52. </Endpoints>
  53.  
  54. netsh.exe http add urlacl url=http://+:%ENDPOINTPORT%/api user=everyone listen=yes delegate=yes
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement