Azure   发布时间:2019-11-03  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了Azure 基础:File Storage大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

title="Azure 基础:File Storage" alt="Azure 基础:File Storage" src="https://cn.js-code.com/res/2019/02-09/09/d93829cf09159b7df8ce9557316719c7.png" >

中介绍了 Blob Storage 的基本用法,本文将介绍 File Storage 的主要使用方法。

Azure 基础:File Storage

https://.file.core.windows.net///

https://nickdemo.file.core.windows.net/demofiles/temp.txt

中的介绍,这里就不重复了。

便查看 C# 代码执行的结果,本文使用了 MS 发布的一个 Azure Storage 客户端工具:http://storageexplorer.com/" target="_blank">Microsoft Azure Storage Explorer,文中简称为 Storage Explorer。下面是 File Storage 的一个截图:

title="Azure 基础:File Storage" alt="Azure 基础:File Storage" src="https://cn.js-code.com/res/2019/02-09/09/4c9876a1d88e5868021179ce4ad03bb9.png" >

CloudStorageAccount storageAccount = CloudStorageAccount.Parse(https;AccountName=xxx;AccountKey=yyy);

<span style="color: #008000">// <span style="color: #008000">CloudFileClient 类是 Windows Azure File service 客户端的逻辑表示,我们需要使用它来配置和执行对 File Storage 的操作。
CloudFileClient fileClient =<span style="color: #000000"> storageAccount.CreateCloudFileClient();
<span style="color: #008000">// <span style="color: #008000">CloudFileShare 表示一个 File Share 对象。
CloudFileShare share =<span style="color: #000000"> fileClient.GetShareReference(shareName);
<span style="color: #008000">// <span style="color: #008000">如果不存在就创建 File Share。
share.CreateIfNotExists();

title="Azure 基础:File Storage" alt="Azure 基础:File Storage" src="https://cn.js-code.com/res/2019/02-09/09/efb55a9a260c2776edfd0f6c3c30581c.png" >

CloudFileDirectory rootDir =); CloudFileDirectory webDir = rootDir.GetDirectoryReference(); ); CloudFile cloudFile = webDir.GetFileReference(); String localFile = <span style="color: #0000ff">using (<span style="color: #0000ff">var fileStream =<span style="color: #000000"> System.IO.File.openRead(localFilE))
{
<span style="color: #008000">//
<span style="color: #008000">上传文件。

<span style="color: #000000"> cloudFile.UploadFromStream(fileStream);
}

title="Azure 基础:File Storage" alt="Azure 基础:File Storage" src="https://cn.js-code.com/res/2019/02-09/09/7f2d726ba99cb97f684d0bbda8cd135f.png" >

CloudFileShare share =Name); CloudFileDirectory rootDir =); CloudFileDirectory webDir = rootDir.GetDirectoryReference();

CloudFile cloudFile = webDir.GetFileReference(<span style="color: #800000">"<span style="color: #800000">web.log<span style="color: #800000">"<span style="color: #000000">);
<span style="color: #0000ff">if<span style="color: #000000"> (cloudFile.Exists())
{
<span style="color: #008000">//<span style="color: #008000">由 web.log 文件创建 web.copy.log 文件。
CloudFile copyFile = webDir.GetFileReference(<span style="color: #800000">"<span style="color: #800000">web.copy.log<span style="color: #800000">"<span style="color: #000000">);
copyFile.StartCopy(cloudFilE);
}

title="Azure 基础:File Storage" alt="Azure 基础:File Storage" src="https://cn.js-code.com/res/2019/02-09/09/e0aeaaa28894f5b0ce22697ccf467826.png" >

前面我们提到每个 Share 中最多能存放 5TB 的数据。但有时可能需要限制一下它的最大值,比如最多只能存放 1TB 的数据:

share.Properties.Quota = );

s.Quota 属性的值就可以了。

cmdkey /add:.file.core.windows.net /user: /pass: net use z: \\.file.core.windows.net\mylogs

和 < storage-account-key >进行替换。

net use z: \\.file.core.windows.net\mylogs

title="Azure 基础:File Storage" alt="Azure 基础:File Storage" src="https://cn.js-code.com/res/2019/02-09/09/f0efe6488f57afd0d10a6705c18ecfe6.png" >

虽然我们看到 File Storage 和前文中介绍的 Blob Storage 存在着很多相似的地方,但本质上它们是不一样的。Blob Storage 本质上是一个个网络上的文件,而 File Storage 则是通过 SMB 协议实现的网络共享文件,能够被操作系统映射成本地的磁盘是其最大特征。也只有这一点才能让应用程序通过文件操作 API 完成对远程文件的访问。

大佬总结

以上是大佬教程为你收集整理的Azure 基础:File Storage全部内容,希望文章能够帮你解决Azure 基础:File Storage所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: