使用Azure时如何解决此错误“AddressAccessDeniedException”?

时间:2016-11-10 17:24:36

标签: wcf azure azure-web-sites

我有一个托管在ASP.NET Web应用程序中的WCF服务,在Azure中作为App Service运行。

在本地计算机上运行此项目时没有错误。但是当部署到Azure时,我有以下错误:

  

[AddressAccessDeniedException:HTTP无法注册URL   http://+:80/docs/。您的进程无权访问此权限   命名空间(参见http://go.microsoft.com/fwlink/?LinkId=70353 for   细节)。]

关于本地机器的这个错误有很多帖子,但与azure无关。 Theu建议运行netsh来授予url权限,但我不知道如何在Azure中执行此操作。

实际上我正在尝试使用Swagger进行WCF实现,并且此代码中出现错误:

的Global.asax.cs:

void Application_Start(object sender, EventArgs e)
{
    // Swagger
    RouteTable.Routes.Add(new ServiceRoute("api-docs", new WebServiceHostFactory(), typeof(SwaggerWcfEndpoint)));
    var swaggerHost = new WebServiceHost(typeof(SwaggerWcfEndpoint));
    swaggerHost.Open();
  }

的Web.config:

<services>
  <service name="SwaggerWcf.SwaggerWcfEndpoint">
    <endpoint address="http://totvsrmwebapp.azurewebsites.net/docs" binding="webHttpBinding" contract="SwaggerWcf.ISwaggerWcfEndpoint" />
  </service>
</services>

这里是堆栈跟踪:

'[HttpListenerException (0x5): Access is denied]
   System.Net.HttpListener.SetupV2Config() +333
   System.Net.HttpListener.Start() +297
   System.ServiceModel.Channels.SharedHttpTransportManager.OnOpen() +651

[AddressAccessDeniedException: HTTP could not register URL http://+:80/docs/. Your process does not have access rights to this namespace (see http://go.microsoft.com/fwlink/?LinkId=70353 for details).]
   System.ServiceModel.Channels.SharedHttpTransportManager.OnOpen() +1473
   System.ServiceModel.Channels.TransportManager.Open(TransportChannelListener channelListener) +296
   System.ServiceModel.Channels.TransportManagerContainer.Open(SelectTransportManagersCallback selectTransportManagerCallback) +122
   System.ServiceModel.Channels.TransportChannelListener.OnOpen(TimeSpan timeout) +64
   System.ServiceModel.Channels.HttpChannelListener`1.OnOpen(TimeSpan timeout) +67
   System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) +308
   System.ServiceModel.Dispatcher.ChannelDispatcher.OnOpen(TimeSpan timeout) +61
   System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) +308
   System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout) +136
   System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) +308
   RMWCFWebApp.Global.Application_Start(Object sender, EventArgs e) +236

[HttpException (0x80004005): HTTP could not register URL http://+:80/docs/. Your process does not have access rights to this namespace (see http://go.microsoft.com/fwlink/?LinkId=70353 for details).]
   System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app) +9982013
   System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +118
   System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +172
   System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +336
   System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +296

[HttpException (0x80004005): HTTP could not register URL http://+:80/docs/. Your process does not have access rights to this namespace (see http://go.microsoft.com/fwlink/?LinkId=70353 for details).]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9963380
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254'

1 个答案:

答案 0 :(得分:1)

我已转载您的问题。根据我的经验,Azure网络应用程序不允许我们注册网址&#34; http://totvsrmwebapp.azurewebsites.net/docs&#34;。如果你想这样做,我建议你使用Azure云服务,并在启动任务中执行命令(netsh http add urlacl url =)。有关云服务的更多信息,请参阅this article。并查看this article以了解如何使用启动任务。