简体   繁体   中英

Azure App.Config SharedAccessSignature Error

I am trying to create a WCF service. Which will be authenticated by Windows Azure Service Bus.

My app.config is like below

<tokenProvider>
<sharedAccessSignature keyName="" key=""/>
</tokenProvider>

While running WCF in WCF test client I am getting below error.

System.Configuration.ConfigurationErrorsException: Unrecognized element 'sharedAccessSignature'

Thanks

The following example illustrates how to create a WCF service that can be reached through a Service Bus relay:

Define the service like this in the .svc file:

<%@ ServiceHost Language="C#" Debug="true" Service="ProblemSolver" CodeBehind="ProblemSolver.svc.cs" %>

Note that ProblemSolver implements an interface named IProblemSolver that specifies the service contract.

The relevant parts of my web.config file look like this:

<configuration>
...
<system.serviceModel>
  <behaviors>
    <endpointBehaviors>
      <behavior name="sharedAccessSignatureClientCredentials">
        <transportClientEndpointBehavior>
          <tokenProvider>
            <sharedAccessSignature keyName="RootManageSharedAccessKey" key="[YourSharedAccessSignature]" />
          </tokenProvider>
        </transportClientEndpointBehavior>
      </behavior>
    </endpointBehaviors>
  </behaviors>
  <bindings>
    <netTcpRelayBinding>
      <binding name="default" />
    </netTcpRelayBinding>
  </bindings>
  <services>
    <service name="ProblemSolver">
      <endpoint address="sb://[YourServiceBusNamespace].servicebus.windows.net/solver" behaviorConfiguration="sharedAccessSignatureClientCredentials"
        binding="netTcpRelayBinding" bindingConfiguration="default"
        name="RelayEndpoint" contract="IProblemSolver" />
    </service>
  </services>
  <extensions>
    ...
  </extensions>
</system.serviceModel>
...
</configuration>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM