使用Azure Blob存储
可以通过多种方式来对Azure Blob进行操作。在此我们介绍通过VS的客户端及代码两种方式来操作Blob。
一、通过VS来操作Blob.
1.首先下载publish settings 文件:打开“https://manage.windowsazure.cn/publishsettings/index”,登陆China Azure,下载publish Settings文件到本地。

2. 打开Visual Studio, 选择
View -> Server Explorer

3. 在左侧面板,右键点击Windows Azure, 选择Manage
Subscriptions;

4. 在Manage Microsoft Azure Subscriptions中点击Certificates(0)选项卡。 点击Import,把第一步下载的Publish settings文件导入

5.展开Azure->Storage下的存储(我的存储实例为terryteststorage)

6. 点击存储实例下的Blobs即可查看此存储下有哪些Container及每个Container下存储的数据信息。

7. 上传文件到指定的Container。先在Blobs上右击,然后选择Create Blob Container,然后弹出创建Container页面。


8. 输入Container名称”test1”,然后点击OK按钮。

9.至此,test1已创建成功,test1中未有任何数据

10. 上传文件到test1中。点击页面上方的Upload Blob按钮

11. 在弹出的上传控件中选择要上传的文件后,单击OK按钮。

12. 至此,选择的文件已上传到test1中。

二、通过 Storage API来创建Container、显示Container及上传文件到指定的Container.
1. 创建AzureBlockStorage类型工程, 输入工程名称” DataBlobStorageExample”,点击OK.

2. 具体代码实例如下:
static StorageCredentials credentials = new StorageCredentials("terryteststorage", "0HnFgkllVNf7m0dTBM/U7hbC96o/YUVH ==");
static CloudStorageAccount storageAccount = new CloudStorageAccount(credentials,new Uri("https://terryteststorage.blob.core.chinacloudapi.cn/"),
new Uri("https://terryteststorage.queue.core.chinacloudapi.cn/"),
new Uri("https://terryteststorage.table.core.chinacloudapi.cn/"),null);
static void Main(string[] args)
{
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
//create container
CloudBlobContainer container = blobClient.GetContainerReference("container1");
container.CreateIfNotExists();
//List containers
List<CloudBlobContainer> containers ;
if (ListContainers(out containers))
{
if (containers != null)
{
foreach (CloudBlobContainer container2 in containers)
{
Console.Write(container2.Name + " ");
}
Console.WriteLine();
}
}
//put file to blob
PutBlob("container1", "blob1.txt", "This is a text blob!");
}
public static bool ListContainers(out List<CloudBlobContainer> containerList)
{
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
containerList = new List<CloudBlobContainer>();
try
{
IEnumerable<CloudBlobContainer> containers = blobClient.ListContainers();
if (containers != null)
{
containerList.AddRange(containers);
}
return true;
}
catch (Exception ex)
{
throw;
}
}
public static bool PutBlob(string containerName, string blobName, string content)
{
try
{
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
CloudBlobContainer container = blobClient.GetContainerReference(containerName);
ICloudBlob blob = container.GetBlockBlobReference(blobName);
string filePath = @"D:\Terry\blocktest.txt";
blob.UploadFromFile(filePath, FileMode.OpenOrCreate);
return true;
}
catch (Exception ex)
{
Console.WriteLine("error in Putblock");
}
}
3. 运行结果


使用Azure Blob存储的更多相关文章
- 通过 PHP 连接China Azure Blob 存储
问题说明 Azure Blob 存储是一种将非结构化数据作为对象/Blob存储在云中的服务.Blob存储可以存储任何类型的文本或二进制数据,例如文档.媒体文件或应用程序安装程序.Blob存储也称为对象 ...
- ASP.NET Core 2.0中的Azure Blob存储
问题 如何在ASP.NET Core中使用Azure Blob存储 解 创建一个类库并添加NuGet包 - WindowsAzure.Storage 添加一个类来封装设置, publicclass A ...
- Azure Blob 存储简介
Azure Blob 存储是 Microsoft 提供的适用于云的对象存储解决方案. Blob 存储最适合存储巨量的非结构化数据. 非结构化数据是不遵循特定数据模型或定义(如文本或二进制数据)的数据. ...
- Azure Blob存储更改缓存时间
Azure的Blob存储可以作为Http的服务来使用.很多客户已经把Blob作为图片存储的服务,这样稍作代码的修改,解决了图片服务器带宽.性能等多种问题. 但同时问题也出现了:在传统Http的服务中很 ...
- .NET 使用 Azure Blob 存储图片或文件
使用的是VS2017 一.先使用 NuGet 获取这两个包. 执行以下步骤: 在“解决方案资源管理器”中,右键单击你的项目并选择“管理 NuGet 包”. 1.在线搜索“WindowsAzure.St ...
- Azure Storage 系列(二) .NET Core Web 项目中操作 Blob 存储
一,引言 上一篇文章,我们介绍到在实际项目中系统会产生大量的日志文件,用户上传的头像等等,同时也介绍到可以使用Azure Blob Storage 来存储项目中的一些日志文件,用户头像,用户视频等等. ...
- 微软开放技术发布开源 Jenkins 插件以将 Windows Azure Blob 服务用的开作存储库
发布于 2014-02-10 作者 陈 忠岳 持续集成 (CI) 的历史源远流长, 其宗旨在于软件团队在敏捷环境中不断将他们的工作整合为持续构建.管理 CI 进程的工具已存在一段时间.过去几年中 ...
- AzCopy – 上传/下载 Windows Azure Blob 文件
在我们收到的请求中,有一个频繁出现的请求是提供一种能在 Windows Azure Blob 存储与其本地文件系统之间轻松上传或下载文件的方法.一年半前, 我们很高兴地发布了 AzCopy, Wind ...
- 使用 Azure 创建存储和检索文件
本指南将以循序渐进的方式帮助您使用 Azure 将文件存储到云中.我们将逐一介绍如何创建存储账户.创建容器.上传文件.检索文件和删除文件.在本教程中完成的所有操作均符合 1 元试用条件. 本指南将以循 ...
随机推荐
- 105 董婷婷 第二次Sprint总结
总结: 第二次冲刺结束了,这次冲刺的主要任务是建立数据库.项目进行到现在也基本定型了,满满的成就感啊.经过一段时间的合作,团队成员间的默契大大提高,还有最后一次冲刺,队友们,加油哦!
- PHP实例开发(3)PHP中MVC学习之ThinkPHP
PHP中MVC学习之ThinkPHP 1.什么是MVC MVC本来是存在于Desktop程序中的,M是指数据模型,V是指用户界面,C则是控制器.使用MVC的目的是将M和V的实现代码分离 MVC是一个设 ...
- Tomcat编码配置解疑
环境:tomcat6.0.23 jdk 1.6 相关参考: http://tomcat.apache.org/tomcat-7.0-doc/config/ajp.html http://wiki.ap ...
- [C# WPF]MoeEroViewer Developing Log
[C# WPF]MoeEroViewer Developing Log 1st - Base Document run on Https://github.com/Amarillys/MoeEroVi ...
- (转)LINUX测试环境部署Redis(四)
安装配置Redis 第一部分:安装redis 希望将redis安装到此目录 1 /usr/local/redis 希望将安装包下载到此目录 1 /usr/local/src 那么安装过程指令如下: ...
- C(C++)输入输出格式
c&c++输入输出控制格式 许多情况下,都需要控制输出结果的表现形式.如输出宽度.输出精度.输出格式等.C++的iomanip.h中定义了许多控制符,这些控制符可以直接插入到流中,控制数据的输 ...
- mysql总结
//查询日期之前的差距 select user_name , from_unixtime(user_lastlogin_time),now() , year(now())- ...
- 解决魅族MX5卸载debug-app不干净,导致安装、升级不成功的问题
环境:魅族MX5,Android 5.1 问题:开发app使用真机调试后,在桌面上拖动图标卸载app-debug.apk,然后安装签名版本的app-release.apk提示替换xxx版本,按确定后提 ...
- 调试新技能get - powershell
1. win+r -> powershell_ise 2. debug-process 3. type processname....WITHOUT ".exe"
- GraphicsMagick+Im4Java在windows和linux下的配置
GraphicsMagick介绍及安装 Im4Java包为: im4java-1.2.0.jar 直接在lib下引用即可 GraphicsMagick的安装如下: windows下: 安装:Graph ...