

 **This page is only for existing customers of the Amazon Glacier service using Vaults and the original REST API from 2012.**

If you're looking for archival storage solutions, we recommend using the Amazon Glacier storage classes in Amazon S3, S3 Glacier Instant Retrieval, S3 Glacier Flexible Retrieval, and S3 Glacier Deep Archive. To learn more about these storage options, see [Amazon Glacier storage classes](https://www.amazonaws.cn/s3/storage-classes/glacier/).

Amazon Glacier (original standalone vault-based service) is no longer accepting new customers. Amazon Glacier is a standalone service with its own APIs that stores data in vaults and is distinct from Amazon S3 and the Amazon S3 Glacier storage classes. Your existing data will remain secure and accessible in Amazon Glacier indefinitely. No migration is required. For low-cost, long-term archival storage, Amazon recommends the [Amazon S3 Glacier storage classes](https://www.amazonaws.cn/s3/storage-classes/glacier/), which deliver a superior customer experience with S3 bucket-based APIs, full Amazon Web Services Region availability, lower costs, and Amazon service integration. If you want enhanced capabilities, consider migrating to Amazon S3 Glacier storage classes by using our [Amazon Solutions Guidance for transferring data from Amazon Glacier vaults to Amazon S3 Glacier storage classes](https://www.amazonaws.cn/solutions/guidance/data-transfer-from-amazon-s3-glacier-vaults-to-amazon-s3/).

# Using the Amazon SDK for .NET with Amazon Glacier
<a name="using-aws-sdk-for-dot-net"></a>

The Amazon SDK for .NET API is available in `AWSSDK.dll`. For information about downloading the Amazon SDK for .NET, go to [Sample Code Libraries](http://www.amazonaws.cn/sdkfornet/). As described in [Using the Amazon SDKs with Amazon Glacier](using-aws-sdk.md), the Amazon SDK for .NET provides both the high-level and low-level APIs. 

**Note**  
The low-level API and high-level API provide thread-safe clients for accessing Amazon Glacier. As a best practice, your applications should create one client and reuse the client between threads.

**Topics**
+ [Using the Low-Level API](#about-low-level-dotnet-api)
+ [Using the High-Level API](#about-high-level-dotnet-api)
+ [Running Code Examples](#setting-up-and-testing-sdk-dotnet)
+ [Setting the Endpoint](#setting-sdk-dot-net-endpoint)

## Using the Low-Level API
<a name="about-low-level-dotnet-api"></a>

The low-level `AmazonGlacierClient` class provides all the methods that map to the underlying REST operations of Amazon Glacier (Amazon Glacier) ( [API Reference for Amazon Glacier](amazon-glacier-api.md)). When calling any of these methods, you must create a corresponding request object and provide a response object in which the method can return a Amazon Glacier response to the operation. 

For example, the `AmazonGlacierClient` class provides the `CreateVault` method to create a vault. This method maps to the underlying Create Vault REST operation (see [Create Vault (PUT vault)](api-vault-put.md)). To use this method, you must create instances of the `CreateVaultRequest` and `CreateVaultResponse` classes to provide request information and receive a Amazon Glacier response as shown in the following C\# code snippet:

 

```
AmazonGlacierClient client;
client = new AmazonGlacierClient(Amazon.RegionEndpoint.USEast1); 

CreateVaultRequest request = new CreateVaultRequest()
{
  AccountId = "-",
  VaultName = "*** Provide vault name ***"
};

CreateVaultResponse response = client.CreateVault(request);
```

All the low-level samples in the guide use this pattern. 

 

**Note**  
The preceding code segment specifies `AccountId` when creating the request. However, when using the Amazon SDK for .NET, the `AccountId` in the request is optional, and therefore all the low-level examples in this guide don't set this value. The `AccountId` is the Amazon Web Services account ID. This value must match the Amazon Web Services account ID associated with the credentials used to sign the request. You can specify either the Amazon Web Services account ID or optionally a '-', in which case Amazon Glacier uses the Amazon Web Services account ID associated with the credentials used to sign the request. If you specify your Account ID, do not include hyphens in it. When using Amazon SDK for .NET, if you don't provide the account ID, the library sets the account ID to '-'. 

## Using the High-Level API
<a name="about-high-level-dotnet-api"></a>

To further simplify your application development, the Amazon SDK for .NET provides the `ArchiveTransferManager` class that implements a higher-level abstraction for some of the methods in the low-level API. It provides useful methods, such as `Upload` and `Download`, for the archive operations. 

For example, the following C\# code snippet uses the `Upload` high-level method to upload an archive. 

 

```
string vaultName = "examplevault";
string archiveToUpload = "c:\folder\exampleArchive.zip";

var manager = new ArchiveTransferManager(Amazon.RegionEndpoint.USEast1);
string archiveId = manager.Upload(vaultName, "archive description", archiveToUpload).ArchiveId;
```

Note that any operations you perform apply to the Amazon Region you specified when creating the `ArchiveTransferManager` object. All the high-level examples in this guide use this pattern. 

 

**Note**  
The high-level `ArchiveTransferManager` class still needs the low-level `AmazonGlacierClient` client, which you can pass either explicitly or the `ArchiveTransferManager` creates the client.

## Running Code Examples
<a name="setting-up-and-testing-sdk-dotnet"></a>

The easiest way to get started with the .NET code examples is to install the Amazon SDK for .NET. For more information, go to [Amazon SDK for .NET](http://www.amazonaws.cn/sdkfornet/). 

The following procedure outlines steps for you to test the code examples provided in this guide.


**General Process of Creating .NET Code Examples (Using Visual Studio)**  

|  |  | 
| --- |--- |
| 1 | Create a credentials profile for your Amazon credentials as described in the Amazon SDK for .NET topic [Configuring Amazon credentials](http://docs.amazonaws.cn/sdk-for-net/v4/developer-guide/creds-assign.html). | 
| 2 | Create a new Visual Studio project using the *Amazon Empty Project* template.  | 
| 3 | Replace the code in the project file, `Program.cs`, with the code in the section you are reading.  | 
| 4 |  Run the code. Verify that the object is created using the Amazon Web Services Management Console. For more information about Amazon Web Services Management Console, go to [http://www.amazonaws.cn/console/](http://www.amazonaws.cn/console/). | 

## Setting the Endpoint
<a name="setting-sdk-dot-net-endpoint"></a>

By default, the Amazon SDK for .NET sets the endpoint to the US West (Oregon) Region (`https://glacier.us-west-2.amazonaws.com.cn`). You can set the endpoint to other Amazon Regions as shown in the following C\# snippets.

The following snippet shows how to set the endpoint to the US West (Oregon) Region (`us-west-2`) in the low-level API.

**Example**  

```
AmazonGlacierClient client = new AmazonGlacierClient(Amazon.RegionEndpoint.USWest2);
```

The following snippet shows how to set the endpoint to the US West (Oregon) Region in the high-level API.

 

```
var manager = new ArchiveTransferManager(Amazon.RegionEndpoint.USWest2);
```

For a current list of supported Amazon Regions and endpoints, see [Accessing Amazon Glacier](amazon-glacier-accessing.md).