Microsoft Azure Storage(微软Blob存储)

登陆到直接自己的账号后,创建一个存储账户

Microsoft Azure Storage(微软Blob存储)

进去之后就这个样子:

Microsoft Azure Storage(微软Blob存储)

 访问密钥就是这个新建的Blob的链接字符串和密钥:

Microsoft Azure Storage(微软Blob存储)

 还要装的是一个客户端Microsoft Azure Storage Explorer 用来操控数据,类似数据库sql

Microsoft Azure Storage(微软Blob存储)

 然后贴进去链接字符串,这一步我操作的时候有点时间缓慢,等一会,不需要暂停重新链接,否则,可能会有两个链接名字

Microsoft Azure Storage(微软Blob存储)

 链接ok

Microsoft Azure Storage(微软Blob存储)

现在开始试着往Blob中上传一个文件试试看:就随便上传一个应用程序。如图所示:

客户端是有的,没问题。

Microsoft Azure Storage(微软Blob存储)

 下面是上传:这个是下载

            var account = CloudStorageAccount.Parse("DefaultEndpointsProtocol=httpxxxxxxxxxxxxxxxxxx=core.chinacloudapi.cn");
            var blobClient = account.CreateCloudBlobClient();
            //这个container的名字必须是已经存在的容器名,否则上传不进去,云上没有资料
            string container = "bobtest";
            string FileName = "Prozkb";           

            var blobContainer = blobClient.GetContainerReference(container);
            //check folder
            string yy = DateTimeOffset.Now.Year.ToString();
            string mm = DateTimeOffset.Now.Month.ToString();
            string dd = DateTimeOffset.Now.Day.ToString();
            string filename = $"{yy}/{mm}/{dd}/{FileName}.pdf";//这个文件名字也是可以换成任何格式的。

            var cloudBlockBlob = blobContainer.GetBlockBlobReference(filename);
            byte[] fileByte = Encoding.UTF8.GetBytes("123456789");
            Task.Run(() => { return cloudBlockBlob.UploadFromStreamAsync(byte2stream(fileByte)); });
            //这个是返回的url,浏览器中好像不能直接读取
            string s= cloudBlockBlob.Uri.ToString();

结果就是这样的:两个都有的。上面是上传的代码。

Microsoft Azure Storage(微软Blob存储)

Blob就暂时这样子吧!