教程:使用 Blob 存储构建高度可用的应用程序Tutorial: Build a highly available application with Blob storage

本教程是一个系列中的第一部分。This tutorial is part one of a series. 本教程介绍如何在 Azure 中实现应用程序数据的高可用性。In it, you learn how to make your application data highly available in Azure.

完成本教程后,将会生成一个控制台应用程序,用于上传 Blob 并从读取访问异地冗余 (RA-GRS) 存储帐户检索它。When you've completed this tutorial, you will have a console application that uploads and retrieves a blob from a read-access geo-redundant (RA-GRS) storage account.

Azure 存储中的异地冗余会将事务从主要区域异步复制到数百英里外的次要区域。Geo-redundancy in Azure Storage replicates transactions asynchronously from a primary region to a secondary region that is hundreds of miles away. 此复制过程可确保次要区域中的数据最终一致。This replication process guarantees that the data in the secondary region is eventually consistent. 控制台应用程序使用断路器模式确定要连接到的终结点,在模拟故障和恢复时在终结点之间自动切换。The console application uses the circuit breaker pattern to determine which endpoint to connect to, automatically switching between endpoints as failures and recoveries are simulated.

如果没有 Azure 订阅,请在开始前创建一个试用帐户If you don't have an Azure subscription, create a trial account before you begin.

在该系列的第一部分中,你会学习如何:In part one of the series, you learn how to:

  • 创建存储帐户Create a storage account
  • 设置连接字符串Set the connection string
  • 运行控制台应用程序Run the console application

先决条件Prerequisites

完成本教程:To complete this tutorial:

我们目前正在努力创建反映 Azure 存储客户端库 12.x 版的代码片段。We are currently working to create code snippets reflecting version 12.x of the Azure Storage client libraries. 有关详细信息,请参阅宣布推出 Azure 存储 v12 客户端库For more information, see Announcing the Azure Storage v12 Client Libraries.

登录到 Azure 门户Sign in to the Azure portal

登录 Azure 门户Sign in to the Azure portal.

创建存储帐户Create a storage account

存储帐户提供唯一的命名空间来存储和访问 Azure 存储数据对象。A storage account provides a unique namespace to store and access your Azure Storage data objects.

按以下步骤创建读取访问异地冗余存储帐户:Follow these steps to create a read-access geo-redundant storage account:

  1. 在 Azure 门户中选择“创建资源”按钮。Select the Create a resource button in the Azure portal.

  2. 从“新建”页中选择“存储帐户 - blob、文件、表、队列”。Select Storage account - blob, file, table, queue from the New page.

  3. 使用以下信息填充存储帐户窗体(如下图所示),然后选择“创建”:Fill out the storage account form with the following information, as shown in the following image and select Create:

    设置Setting       示例值Sample value 说明Description
    订阅Subscription 我的订阅My subscription 有关订阅的详细信息,请参阅订阅For details about your subscriptions, see Subscriptions.
    ResourceGroupResourceGroup myResourceGroupmyResourceGroup 如需有效的资源组名称,请参阅 Naming rules and restrictions(命名规则和限制)。For valid resource group names, see Naming rules and restrictions.
    名称Name mystorageaccountmystorageaccount 存储帐户的唯一名称。A unique name for your storage account.
    位置Location 中国东部 2China East 2 选择一个位置。Choose a location.
    “性能”Performance 标准Standard 对于示例方案,“标准”性能是一个不错的选项。Standard performance is a good option for the example scenario.
    帐户类型Account kind StorageV2StorageV2 建议使用常规用途 v2 存储帐户。Using a general-purpose v2 storage account is recommended. 有关 Azure 存储帐户类型的详细信息,请参阅存储帐户概述For more information on types of Azure storage accounts, see Storage account overview.
    复制Replication 读取访问异地冗余存储 (RA-GRS)Read-access geo-redundant storage (RA-GRS) 主要区域是异地冗余区域,将在启用了对次要区域的读取访问权限的情况下复制到次要区域。The primary region is geo-redundant and is replicated to a secondary region, with read access to the secondary region enabled.
    访问层Access tier 热访问层Hot 将热访问层用于经常访问的数据。Use the hot tier for frequently-accessed data.

    创建存储帐户

下载示例Download the sample

我们目前正在努力创建反映 Azure 存储客户端库 12.x 版的代码片段。We are currently working to create code snippets reflecting version 12.x of the Azure Storage client libraries. 有关详细信息,请参阅宣布推出 Azure 存储 v12 客户端库For more information, see Announcing the Azure Storage v12 Client Libraries.

配置示例Configure the sample

我们目前正在努力创建反映 Azure 存储客户端库 12.x 版的代码片段。We are currently working to create code snippets reflecting version 12.x of the Azure Storage client libraries. 有关详细信息,请参阅宣布推出 Azure 存储 v12 客户端库For more information, see Announcing the Azure Storage v12 Client Libraries.

运行控制台应用程序Run the console application

我们目前正在努力创建反映 Azure 存储客户端库 12.x 版的代码片段。We are currently working to create code snippets reflecting version 12.x of the Azure Storage client libraries. 有关详细信息,请参阅宣布推出 Azure 存储 v12 客户端库For more information, see Announcing the Azure Storage v12 Client Libraries.

了解示例代码Understand the sample code

我们目前正在努力创建反映 Azure 存储客户端库 12.x 版的代码片段。We are currently working to create code snippets reflecting version 12.x of the Azure Storage client libraries. 有关详细信息,请参阅宣布推出 Azure 存储 v12 客户端库For more information, see Announcing the Azure Storage v12 Client Libraries.

后续步骤Next steps

本系列教程的第一部分介绍了如何使用 RA-GRS 存储帐户实现应用程序的高可用性。In part one of the series, you learned about making an application highly available with RA-GRS storage accounts.

若要了解如何模拟故障并强制应用程序使用辅助 RA-GRS 终结点,请转到此系列的第二部分。Advance to part two of the series to learn how to simulate a failure and force your application to use the secondary RA-GRS endpoint.