Windows Azure Storage (25) Azure Append Blob
2017-11-27 16:22
447 查看
《Windows Azure Platform 系列文章目录》
在笔者之前的文章中,我们介绍了Azure Blob 有两种:Block Blob和Page Blob。
在这里笔者介绍Blob的第三种:Append Blob。
概念:
1.Append Blob概念类似于Block Blob,因为都是由块组成的
2.单个Block Blob可以包含最多50000个块,每个块最大100MB,总大小大约4.75TB (100MB * 50000)。
3.Append Blob针对追加操作进行了优化,特别适合与日志记录方案
4.Append Blob可以包含最多50000个块,每个块最大4MB。总大小约为195GB
5.Append Blob不支持修改和删除,每个对Append Blob的操作,都会追加到Append Blob的末尾。
我们这里写一个.NET的Sample Code:
如果我们执行代码两次,然后通过Azure Storage Explorer查看这个TXT文件,就可以看到文件被追加到Azure Append Blob里面了。
在笔者之前的文章中,我们介绍了Azure Blob 有两种:Block Blob和Page Blob。
在这里笔者介绍Blob的第三种:Append Blob。
概念:
1.Append Blob概念类似于Block Blob,因为都是由块组成的
2.单个Block Blob可以包含最多50000个块,每个块最大100MB,总大小大约4.75TB (100MB * 50000)。
3.Append Blob针对追加操作进行了优化,特别适合与日志记录方案
4.Append Blob可以包含最多50000个块,每个块最大4MB。总大小约为195GB
5.Append Blob不支持修改和删除,每个对Append Blob的操作,都会追加到Append Blob的末尾。
我们这里写一个.NET的Sample Code:
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using Microsoft.WindowsAzure.Storage; using System.Configuration; using Microsoft.WindowsAzure.Storage.Blob; using System.IO; namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { CloudStorageAccount cloudStorageAccount = CloudStorageAccount.Parse(ConfigurationManager.AppSettings["AzureStorageConnectionString"]); CloudBlobClient cloudBlobClient = cloudStorageAccount.CreateCloudBlobClient(); //Container Name必须为小写 CloudBlobContainer cloudBlobContainer = cloudBlobClient.GetContainerReference("appendblobcontainer"); cloudBlobContainer.CreateIfNotExists(); CloudAppendBlob cloudAppendBlob = cloudBlobContainer.GetAppendBlobReference("helloworld.txt"); //如果不存在,则创建该文件 if(!cloudAppendBlob.Exists()) { cloudAppendBlob.CreateOrReplace(); } var tasks = new Task[100]; for (int i = 0; i < 100; i++) { var message = string.Format("Appending log number {0} to an append blob.\r\n", i); var bytes = Encoding.UTF8.GetBytes(message); var stream = new MemoryStream(bytes); tasks[i] = cloudAppendBlob.AppendBlockAsync(stream); } Task.WaitAll(tasks); string appendBlobContent = cloudAppendBlob.DownloadText(); } } }
如果我们执行代码两次,然后通过Azure Storage Explorer查看这个TXT文件,就可以看到文件被追加到Azure Append Blob里面了。
相关文章推荐
- Windows Azure Storage (3) Windows Azure Storage Service存储服务之Blob详解(中)
- Windows Azure Introduction - Storage: Blob
- Windows Azure Storage (4) Windows Azure Storage Service存储服务之Blob Share Access Signature
- Windows Azure Storage (2) Windows Azure Storage Service存储服务之Blob详解(上)
- Windows Azure Storage (11) 计算你存储的Blob的大小
- Windows Azure Storage (19) 再谈Azure Block Blob和Page Blob
- [Windows Azure] How to use the Windows Azure Blob Storage Service in .NET
- [New Portal]Windows Azure Storage (14) 使用Azure Blob的PutBlock方法,实现文件的分块、离线上传
- [New Portal]Windows Azure Storage (13) 本地冗余存储 vs 地理冗余存储 (下)
- WindowsAzure.StorageClient API
- Designing Data Storage Architecture-Windows Azure Storage Abstractions and their Scalability Targets
- 微软开放技术发布开源 Jenkins 插件以将 Windows Azure Blob 服务用的开作存储库
- 宣布降低Windows Azure Storage的定价
- AzCopy – 上传/下载 Windows Azure Blob 文件
- How Do I: Use Windows Azure Storage with my Application?
- Azure Basic - Windows Storage Enhancement (Blob)
- Using ELMAH in Windows Azure with Table Storage
- Windows Azure Platform (九) Windows Azure Storage Service存储服务
- Windows Azure Table Storage vs. Windows SQL Azure
- Windows Azure Storage (5) Windows Azure Drive