代码之家  ›  专栏  ›  技术社区  ›  Chris Pietschmann

Azure服务总线中继是否可以用于公开ASP。NET托管WCF服务?

  •  2
  • Chris Pietschmann  · 技术社区  · 10 年前

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

    Azure服务总线中继是公开ASP的理想方法。NET WCF服务提供给Azure中托管的应用程序。然而,所有Azure文档都只显示了设置服务总线中继的示例,其中WCF服务托管在Console应用程序中。

    是否可以在ASP。NET应用程序,并通过Azure服务总线中继将其公开?

    2 回复  |  直到 10 年前
        1
  •  0
  •   Aram    10 年前

    我认为你需要的是建立一个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/

        2
  •  0
  •   Chris Pietschmann    10 年前

    Sidney Andrews 在下面的链接中发布了如何配置ASP的示例。NET网站。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>
    

    谢谢西德尼,这正是我需要的!

    推荐文章