【问题标题】:Can Azure Service Bus Relay be used to expose an ASP.NET hosted WCF service?可以使用 Azure 服务总线中继来公开 ASP.NET 托管的 WCF 服务吗?
【发布时间】:2015-12-06 19:47:54
【问题描述】:

我正在处理一个在本地托管 ASP.NET WCF 服务的项目,它需要公开以供 Microsoft Azure 中托管的其他应用程序使用。

Azure 服务总线中继是将 ASP.NET WCF 服务公开给 Azure 中托管的应用程序的理想方法。但是,所有 Azure 文档都只显示了使用托管在控制台应用程序中的 WCF 服务来设置服务总线中继的示例。

是否可以在 IIS 上的 ASP.NET 应用程序中托管 WCF 服务并通过 Azure 服务总线中继公开它?

【问题讨论】:

    标签: asp.net wcf azure azure-servicebusrelay


    【解决方案1】:

    我认为您需要设置一个 Azure 混合连接,该连接专为您正在尝试做的事情而构建:

    这是一个简介:

    https://azure.microsoft.com/en-us/documentation/articles/integration-hybrid-connection-overview/

    设置方法如下:

    https://azure.microsoft.com/en-us/documentation/articles/integration-hybrid-connection-create-manage/

    【讨论】:

    • 这就是我们用来与 Azure 的本地服务对话的内容
    【解决方案2】:

    Sidney Andrews 在以下链接中发布了一个示例,说明如何配置 ASP.NET web.config 文件以使用服务总线中继端点设置 WCF 服务。

    https://gist.github.com/SidneyAndrewsOpsgility/bc1096ac96401f95b3d7

    <?xml version="1.0" encoding="utf-8"?>
    <!--
      For more information on how to configure your ASP.NET application, please visit
      http://go.microsoft.com/fwlink/?LinkId=169433
      -->
    <configuration>
      <system.web>
        <compilation debug="true" targetFramework="4.5.2"/>
        <httpRuntime targetFramework="4.5.2"/>
      </system.web>
      <system.serviceModel>
        <behaviors>
          <serviceBehaviors>
            <behavior name="">
              <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
              <serviceDebug includeExceptionDetailInFaults="true"/>
            </behavior>
          </serviceBehaviors>
          <endpointBehaviors>
            <behavior name="ServiceBusBehavior">
              <transportClientEndpointBehavior>
                <tokenProvider>
                  <sharedAccessSignature keyName="RootManageSharedAccessKey" key="[replace with your key]" />
                </tokenProvider>
              </transportClientEndpointBehavior>
            </behavior>
          </endpointBehaviors>
        </behaviors>
        <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
        <services>
          <service name="WcfTest.Services.ClockService">
            <endpoint address="" binding="basicHttpBinding" bindingConfiguration="DefaultBinding" contract="WcfTest.Services.IClockService"/>
            <endpoint address="sb://[replace with your namespace].servicebus.windows.net/clock" binding="netTcpRelayBinding" behaviorConfiguration="ServiceBusBehavior" contract="WcfTest.Services.IClockService"/>
          </service>
        </services>
        <bindings>
          <basicHttpBinding>
            <binding name="DefaultBinding" />
          </basicHttpBinding>
          <netTcpRelayBinding>
            <binding name="ServiceBusBinding" />
          </netTcpRelayBinding>
        </bindings>
        <extensions>
          <!-- In this extension section we are introducing all known service bus extensions. User can remove the ones they don't need. -->
          <behaviorExtensions>
            <add name="connectionStatusBehavior"
              type="Microsoft.ServiceBus.Configuration.ConnectionStatusElement, Microsoft.ServiceBus, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
            <add name="transportClientEndpointBehavior"
              type="Microsoft.ServiceBus.Configuration.TransportClientEndpointBehaviorElement, Microsoft.ServiceBus, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
            <add name="serviceRegistrySettings"
              type="Microsoft.ServiceBus.Configuration.ServiceRegistrySettingsElement, Microsoft.ServiceBus, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
          </behaviorExtensions>
          <bindingElementExtensions>
            <add name="netMessagingTransport"
              type="Microsoft.ServiceBus.Messaging.Configuration.NetMessagingTransportExtensionElement, Microsoft.ServiceBus,  Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
            <add name="tcpRelayTransport"
              type="Microsoft.ServiceBus.Configuration.TcpRelayTransportElement, Microsoft.ServiceBus, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
            <add name="httpRelayTransport"
              type="Microsoft.ServiceBus.Configuration.HttpRelayTransportElement, Microsoft.ServiceBus, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
            <add name="httpsRelayTransport"
              type="Microsoft.ServiceBus.Configuration.HttpsRelayTransportElement, Microsoft.ServiceBus, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
            <add name="onewayRelayTransport"
              type="Microsoft.ServiceBus.Configuration.RelayedOnewayTransportElement, Microsoft.ServiceBus, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
          </bindingElementExtensions>
          <bindingExtensions>
            <add name="basicHttpRelayBinding"
              type="Microsoft.ServiceBus.Configuration.BasicHttpRelayBindingCollectionElement, Microsoft.ServiceBus, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
            <add name="webHttpRelayBinding"
              type="Microsoft.ServiceBus.Configuration.WebHttpRelayBindingCollectionElement, Microsoft.ServiceBus, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
            <add name="ws2007HttpRelayBinding"
              type="Microsoft.ServiceBus.Configuration.WS2007HttpRelayBindingCollectionElement, Microsoft.ServiceBus, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
            <add name="netTcpRelayBinding"
              type="Microsoft.ServiceBus.Configuration.NetTcpRelayBindingCollectionElement, Microsoft.ServiceBus, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
            <add name="netOnewayRelayBinding"
              type="Microsoft.ServiceBus.Configuration.NetOnewayRelayBindingCollectionElement, Microsoft.ServiceBus, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
            <add name="netEventRelayBinding"
              type="Microsoft.ServiceBus.Configuration.NetEventRelayBindingCollectionElement, Microsoft.ServiceBus, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
            <add name="netMessagingBinding"
              type="Microsoft.ServiceBus.Messaging.Configuration.NetMessagingBindingCollectionElement, Microsoft.ServiceBus, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
          </bindingExtensions>
        </extensions>
      </system.serviceModel>
    </configuration>
    

    谢谢 Sidney,这正是我所需要的!

    【讨论】:

      猜你喜欢
      • 2015-01-09
      • 1970-01-01
      • 2012-02-23
      • 1970-01-01
      • 2011-07-13
      • 2021-05-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多