Exporteren (0) Afdrukken
Alles uitvouwen
Deze inhoud is niet beschikbaar in uw taal, maar wel in het Engels.

How to: Configure a Service Bus Client Using a Configuration File

Updated: March 12, 2015

Once you have defined and implemented a Service Bus interface, you can configure the client application. You can configure your application programmatically or in an App.config file. Configuring your application in an App.config file lets you easily see what the configuration settings are, and to modify the settings after deployment. Note that configuring a Service Bus application by using a configuration file is very similar to configuring a Windows Communication Foundation (WCF) application, which is discussed in Configuring Services Using Configuration Files in the Windows Communication Foundation (WCF) documentation. Therefore, the following discussion is a simplified overview of configuration, with an emphasis on the unique features relevant to Service Bus.

The main difference between configuring a service and a client is that the client must know what configuration settings the service is using, and match them. These settings typically include what type of binding to use, and also what security protocols you must have to access the service (that is, authentication and transport-level security). For more information about setting security, see Securing and Authenticating a Service Bus Connection.

  1. Create the App.config file to define the client endpoint.

    <?xml version="1.0" encoding="utf-8" ?>
          <endpoint name="RelayEndpoint"
                   address="" />    

    Similar to configuring a service application, the minimum parameters that you must have to configure an endpoint are the contract that implements the service, and the type of binding used. The address attribute is the Service Bus address. It can be specified explicitly in the configuration file but is usually constructed programmatically using the CreateServiceUri method. This example also associates an endpoint behavior with the client.

  2. Define the endpoint behavior that contains the security settings.

        <behavior name="sbTokenProvider">
              <sharedAccessSignature keyName="SAS POLICY NAME" key="SAS KEY" />

    In this example, for simplicity the security credentials are defined by using the SAS policy name and key in clear text. Note that this practice can be non-secure: a more secure process (and the process used by many of the Service Bus samples) is to query the user for this information. Alternately, you could decide to encrypt the App.config file to avoid exposing this information.

  3. Define the binding that the client application is to use when it connects to Service Bus.

      <!-- Application Binding -->
        <!-- Default Binding Configuration-->
        <binding name="default" />
  4. You have finished configuring the client application through the App.config file. For more information about creating a Service Bus client application, see Building a Service Bus Client Application.

© 2015 Microsoft