

 **此頁面僅適用於使用 Vaults 和 2012 年原始 REST API 的 Amazon Glacier 服務的現有客戶。**

如果您要尋找封存儲存解決方案，建議您在 Amazon Glacier Instant Retrieval、S3 Glacier Flexible Retrieval 和 S3 Glacier Deep Archive 中使用 Amazon Glacier 儲存類別。 Amazon S3 若要進一步了解這些儲存選項，請參閱 [Amazon Glacier 儲存類別](https://aws.amazon.com/s3/storage-classes/glacier/)。

Amazon Glacier （原始獨立保存庫型服務） 不再接受新客戶。Amazon Glacier 是一項獨立服務，具有自己的 APIs，可將資料存放在保存庫中，並與 Amazon S3 和 Amazon S3 Glacier 儲存類別不同。您現有的資料將在 Amazon Glacier 中無限期保持安全且可存取。不需要遷移。對於低成本、長期的封存儲存， AWS 建議使用 [Amazon S3 Glacier 儲存類別](https://aws.amazon.com/s3/storage-classes/glacier/)，透過 S3 儲存貯體型 APIs、完整 AWS 區域 可用性、降低成本 AWS 和服務整合，提供卓越的客戶體驗。如果您想要增強功能，請考慮使用我們的解決方案指南，將資料從 Amazon S3 Glacier 保存庫傳輸至 Amazon S3 Glacier 儲存類別，以遷移至 Amazon S3 Glacier 儲存類別。 [AWS Amazon Glacier Amazon S3 ](https://aws.amazon.com/solutions/guidance/data-transfer-from-amazon-s3-glacier-vaults-to-amazon-s3/)

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 使用 在 Amazon Glacier 中設定保存庫通知 適用於 .NET 的 AWS SDK
<a name="configuring-notifications-sdk-dotnet"></a>

以下是使用 適用於 .NET 的 AWS SDK低階 API 設定保存庫通知的步驟。

 

1. 建立 `AmazonGlacierClient` 類別的執行個體 (用戶端)。

   您需要指定保存庫所在的 AWS 區域。您使用此用戶端執行的所有操作都會套用到該 AWS 區域。

1. 您可以透過建立 `SetVaultNotificationsRequest` 類別的執行個體，來提供通知組態資訊。

   您需要提供保存庫名稱、通知組態資訊和帳戶 ID。如果您不提供帳戶 ID，則會使用與您提供來簽署請求之登入資料關聯的帳戶 ID。如需詳細資訊，請參閱[適用於 .NET 的 AWS SDK 搭配 Amazon Glacier 使用](using-aws-sdk-for-dot-net.md)。

   在指定通知設定時，您提供現有 Amazon SNS 主題的 Amazon Resource Name (ARN) 和要進行通知的一或多個事件。如需支援的事件清單，請參閱[設定保存庫通知組態 (PUT 通知的組態)](api-vault-notifications-put.md))。

1. 以參數形式提供請求物件，以便執行 `SetVaultNotifications` 方法。

1. 在設定有關保存庫的通知組態之後，您可以透過呼叫 `GetVaultNotifications` 方法擷取組態資訊，以及透過呼叫用戶端所提供的 `DeleteVaultNotifications` 方法將其移除。

## 範例：使用 在保存庫上設定通知組態 適用於 .NET 的 AWS SDK
<a name="creating-vaults-sdk-dotnet-example-notification"></a>

下列 C\# 程式碼範例描述前述步驟。此範例在美國西部 (奧勒岡) 區域設定有關保存庫 (「`examplevault`」) 的通知設定、擷取設定，然後將其刪除。當`ArchiveRetrievalCompleted`事件發生或`InventoryRetrievalCompleted`事件發生時，組態會要求 Amazon Glacier (Amazon Glacier) 傳送通知至指定的 Amazon SNS 主題。

**注意**  
如需基礎 REST API 的資訊，請參閱 [保存庫作業](vault-operations.md)。

如需執行下列範例的逐步說明，請參閱「[執行程式碼範例](using-aws-sdk-for-dot-net.md#setting-up-and-testing-sdk-dotnet)」。您需要如所示更新程式碼，並提供現有的保存庫名稱和 Amazon SNS 主題。

**Example**  

```
using System;
using System.Collections.Generic;
using Amazon.Glacier;
using Amazon.Glacier.Model;
using Amazon.Runtime;

namespace glacier.amazon.com.rproxy.govskope.ca.docsamples
{
  class VaultNotificationSetGetDelete
  {
    static string vaultName   = "examplevault";
    static string snsTopicARN = "*** Provide Amazon SNS topic ARN ***";

    static IAmazonGlacier client;

    public static void Main(string[] args)
    {
      try
      {
        using (client = new AmazonGlacierClient(Amazon.RegionEndpoint.USWest2))
        {
          Console.WriteLine("Adding notification configuration to the vault.");
          SetVaultNotificationConfig();
          GetVaultNotificationConfig();
          Console.WriteLine("To delete vault notification configuration, press Enter");
          Console.ReadKey();
          DeleteVaultNotificationConfig();
        }
      }
      catch (AmazonGlacierException e) { Console.WriteLine(e.Message); }
      catch (AmazonServiceException e) { Console.WriteLine(e.Message); }
      catch (Exception e) { Console.WriteLine(e.Message); }
      Console.WriteLine("To continue, press Enter");
      Console.ReadKey();
    }

    static void SetVaultNotificationConfig()
    {

      SetVaultNotificationsRequest request = new SetVaultNotificationsRequest()
      {     
        VaultName = vaultName,
        VaultNotificationConfig = new VaultNotificationConfig()
        {
          Events   = new List<string>() { "ArchiveRetrievalCompleted", "InventoryRetrievalCompleted" },
          SNSTopic = snsTopicARN
        }
      };
      SetVaultNotificationsResponse response = client.SetVaultNotifications(request);
    }

    static void GetVaultNotificationConfig()
    {
      GetVaultNotificationsRequest request = new GetVaultNotificationsRequest()
      {
        VaultName = vaultName,
        AccountId = "-"
      };
      GetVaultNotificationsResponse response = client.GetVaultNotifications(request);
      Console.WriteLine("SNS Topic ARN: {0}", response.VaultNotificationConfig.SNSTopic);
      foreach (string s in response.VaultNotificationConfig.Events)
        Console.WriteLine("Event : {0}", s);
    }

    static void DeleteVaultNotificationConfig()
    {
      DeleteVaultNotificationsRequest request = new DeleteVaultNotificationsRequest()
      {  
        VaultName = vaultName
      };
      DeleteVaultNotificationsResponse response = client.DeleteVaultNotifications(request);
    }
  }
}
```