Creating an Amazon SQS Client - AWS SDK for .NET (version 3)

This documentation is for version 3.0 of the AWS SDK for .NET, which is mostly centered around .NET Framework and ASP.NET 4.x, Windows, and Visual Studio.

The latest version of the documentation at https://docs.aws.amazon.com/sdk-for-net/latest/developer-guide/ is mostly centered around .NET Core and ASP.NET Core. In addition to Windows and Visual Studio, it gives equal consideration to cross-platform development.

Creating an Amazon SQS Client

You need an Amazon SQS client in order to create and use an Amazon SQS queue. Before configuring your client, you should create an App.Config file to specify your AWS credentials.

You specify your credentials by referencing the appropriate profile in the appSettings section of the file.

The following example specifies a profile named my_profile. For more information about credentials and profiles, see Configuring Your AWS SDK for .NET Application.

<?xml version="1.0"?> <configuration> <configSections> <section name="aws" type="Amazon.AWSSection, AWSSDK.Core"/> </configSections> <aws profileName="my_profile"/> <startup> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/> </startup> </configuration>

After you create this file, you’re ready to create and initialize your Amazon SQS client.

To create and initialize an Amazon SQS client

  1. Create and initialize an AmazonSQSConfig instance, and then set the ServiceURL property with the protocol and service endpoint, as follows.

    var sqsConfig = new AmazonSQSConfig(); sqsConfig.ServiceURL = "http://sqs.us-west-2.amazonaws.com";
  2. Use the AmazonSQSConfig instance to create and initialize an AmazonSQSClient instance, as follows.

    var sqsClient = new AmazonSQSClient(sqsConfig);

You can now use the client to create an Amazon SQS queue. For information about creating a queue, see Creating an Amazon SQS Queue.